Hi!

    I am glad to hear about using VTK and servlets by others too.
The problem is in Your code that the content type is text/html.
I suggest ot try first to set the content type to:
res.setContentType("x-world/x-vrml");
but in MSIE it will not work.


I have managed ot solve the problem only by doig this:
-i have saved in a temp directory the vtk file (taking care that concurent
requests
   not to overwrite ich other). I see that You are doing the same thing try
to save it under the
  public_html dir to be accesible from the WEB.

- i have sent different responses to Netscape and MSIE.


Besrt wishes,
                    Andras.
Please relpy.


Here is the code:

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

vtkVRMLExporter writer=new vtkVRMLExporter();
             writer.SetInput(renWin);

writer.SetFileName("c:/JavaWebServer1.1/public_html/vtk/temp/probahead"+nrfi
s+".wrl");
              writer.Write();
            //nrfis is a global variable incremented for each request



 String browsertype= req.getHeader("User-Agent");


                    if (browsertype.indexOf("MSIE") >= 0 )
                                                {

                                                file://browserul este
Internet Explorer

res.setContentType("text/html");

res.setHeader("Pragma","no-cache");

                                                PrintWriter
toClient=res.getWriter();
                                               toClient.println("<html><body
leftmargin=0 topmargin=0 scroll=no> <embed width=100% height=100%
fullscreen=yes
src=\"http://192.168.0.2:8080/vtk/temp/probahead"+nrfis+".wrl\"></body></htm
l> ");
                                                toClient.close();
                                                }

                                     else {
                                         file://browserul este Netscape

                                res.setContentType("x-world/x-vrml");
                               res.setHeader("Pragma","no-cache");
                               PrintWriter toClient=res.getWriter();
                               LineNumberReader lnr=new LineNumberReader(new
FileReader("c:\\JavaWebServer1.1\\public_html\\vtk\\temp\\probahead"+nrfis+"
.wrl"));
                               String line=new String();
                               while((line=lnr.readLine())!=null)
toClient.println(line);
                               lnr.close();
                               toClient.flush();
                               toClient.close();

                                       }


----- Original Message -----
From: luo hanmei <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 17, 1999 5:58 AM
Subject: problem to open the browser


> Hi, servlet users:
>
> I have tried to include VTK code (visualization toolkit) into the servlet
> which will generate a VRML file, then I want to send this file to the
> client. The problem is that what the client received is just a raw ASCII
> VRML file (.wrl), but I want to invoke the VRML browser whenever the
> client received the VRML file. Following is some of my code. Any
> suggestions is greatly appreaciated!
>
> Hanmei
>
> --------------------------------------------------------------------------
>       response.setContentType("text/html");
>       ServletOutputStream out = response.getOutputStream();
>
>       // Some VTK code here which generates VRML file, i.e. "iso.wrl"
>
>
>       File file = new File("/servlet", "iso.wrl");
>       int size = (int) file.length();
>       response.setContentLength(size);
>
>       byte [] buffer = new byte[size];
>       FileInputStream in = new FileInputStream(file);
>       in.read(buffer);
>       out.write(buffer);   // Output the iso.wrl to the client!

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to