Hi there!

Here is an excerpt from my code. I'm working with a server/client pair. the server 
gets all the necessary information and data from the database on request from the 
client. then the vrml file should be sent right through the stream to the client which 
has to work as an applet. The problem is that the stream only seems to pass an url 
that points to E:\Apache\apache\3dc\BBEARING.wrl
But the BaseURL is http:\\localhost\3dc\BBEARING.wrl.
This of course gives me a Permission Exception for pointing to E:\....
I want to put the file into the stream as a whole, so i don't have to care, because as 
long as i simply read from a stream that contains the file, i won't get any exceptions.

Thanks for any help :-)


Here is my code.


The Serverside:
---------------------------------------------------------

.............


try {

    clientSocket = serverSocket.accept();
       in = new DataInputStream(clientSocket.getInputStream());
       out = new ObjectOutputStream(clientSocket.getOutputStream());

    proto = in.readLine();

if (proto.matches("loadCatalog")) {
 System.out.println(s);
       try {
          //Datenbankanruf
          DBM = new DatabaseManager();
          //load Catalog
          DBM.loadCatalog("jdbc:odbc:testdsn");
          System.out.println("Number of entries:"
          + DBM.getCatalog().getCatalogData().size());
          out.writeObject(DBM.getCatalog());
        } catch (Exception e) {System.out.println(e.toString());}
   }

else

if (proto.startsWith("loadModel")) {


//**************************************************************************

     String fileURL =
     proto.substring(proto.lastIndexOf("http://";),proto.length());
     System.out.println(fileURL);
     String base = fileURL.substring(fileURL.lastIndexOf("/3dc"),
     fileURL.length());
     System.out.println(base);


     File f = new File("E:/apache/Apache/htdocs"+base);
     FileInputStream fo = new FileInputStream(f);

     out.writeObject(f);
     out.close();
   }

//**************************************************************************
  }catch(Exception e) {System.out.println("Has problem: " + e.toString());}
 }
}

..........................

The clientside:
--------------------------------------------------------------

public void getContent() {

    try {
      //create Socket
      clientSocket = new Socket(InetAddress.getLocalHost(), 1234);
      out = new DataOutputStream(clientSocket.getOutputStream());
      in = new ObjectInputStream(clientSocket.getInputStream());
    }
    catch (UnknownHostException e) {System.err.println("Don't know host");}
    catch (IOException e) {
      System.err.println("Couldn't get I/O for the connection");
    }

    if (clientSocket != null && out != null && in != null) {
      try {

        //write message
        out.writeBytes("loadModel"+sourceURL+"\n");


//**************************************************************************
new Thread() {
     public void run() {
         try {

         f = (File) in.readObject();
         FileReader fr = new FileReader(f);
         FileInputStream fis = new FileInputStream(f);

         ProgressMonitorInputStream monitor =
        new ProgressMonitorInputStream(ModelLoader.this,"Reading... ", fis);
         monitor.getProgressMonitor().setMillisToDecideToPopup(0);
         monitor.getProgressMonitor().setMillisToPopup(0);
         monitor.getProgressMonitor().setMinimum(0);
         monitor.getProgressMonitor().setNote("Model wird geladen");
         ProgressMonitor progressMonitor = monitor.getProgressMonitor();

         InputStreamReader is = new InputStreamReader(monitor);

          loader.setBaseUrl(Url);
         System.out.println("The BaseURL is: " + Url);
         scene = loader.load(is);

         fis.close();
         is.close();

         //updates canvas with new Scene
         canvas.updateScene(scene);
         cont.update();
         this.stop();
         in.close();
        }
        catch (Exception e) {System.out.println(e.toString());}
     }
   }.start();
//**************************************************************************
    }
      catch (UnknownHostException e) {
        System.err.println("Trying to connect to unknown host: " + e);
      }
      catch (IOException e) {
        System.err.println("IOException:  " + e);
      }
    }
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to