aspose file tools*
The moose likes Servlets and the fly likes Displaying a HTML file in the new Browser Window using JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Displaying a HTML file in the new Browser Window using JSP" Watch "Displaying a HTML file in the new Browser Window using JSP" New topic
Author

Displaying a HTML file in the new Browser Window using JSP

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
I require to have a JSP page, which would be able to display an HTML file in another browser window.This JSP page would be able to access the HTML files of the system, which may not necessarily be mapped to the same web server.
Hence I need to:

  1. Access the path information of the file
  2. Read the File through InputStreams
  3. Write it using the Outputstream in the new Browser window

  4. We may consider click of a link of a file which would get the file information and display it in a new Browser window
    Is this possible through JSP?
    Thanks in advance.
    Regards,
    ------------------
    Sandeep Desai
    vgdesai@bom3.vsnl.net.in

    1. Sun Certified Java Programmer Scored 93 per cent
    2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
    3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
    4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124
Hi,
One of the simplest ways would be to Read the file and write it out to a web-accessible location. Then spawn a new window (using javascript) pointing to this location.
Alternatively, you will have to use a Jsp page (/servlet) exclusively for the {read file, write file to outstream}
Jsp #1 or even a static HTML page (depends on your needs)

filewriter.jsp

But, the above method needs 2 requests to the server. One for getting the main page (jsp/html) and the other to load the content in a new browser window.
Hope this helps.
Ashwin.
[This message has been edited by Ashwin Desai (edited April 27, 2001).]
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Ashwin,
Is there any way we can open a new browser window through JSP?
Thank you for your views.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

The answer is yes and no.
Opening a new browser is something that takes place entirely on the client. This is the realm of JavaScripting.
JSP can dynamically generate Javascript (or pretty much anything) and this scripting can open a new window.


!_I_Know_Kung_Fu_!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying a HTML file in the new Browser Window using JSP