Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Window open issues in WAR file - JSP  RSS feed

 
dwarakanathan thiru
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am running Jboss portlet where my application (ear) file has JSP within its WAR file.
Now, say in the sever's location there is a PDF file which needs to opened on a seperate window on click of a link provided.
The issue is I cannot use window.open("\usr\bin\resources\somefile.pdf") to open up a file in a specific location (Absolute path).

Is there a simple solution for this? I have also tried using a SERVLET (other alternative) where in the SERVLET i read the absolute path file contents and
write it to the SERVLET OUTPUT STREAM so that a confirmation box comes up to "Open", "Save As" dialog box. Any other simpler solution is welcome.

Now, the 2nd issue is, on click since i am directing the control to the SERVLET, this opens up a new blank window for the SERVLET. I need to avoid this. But retain the home page as it is. Can iFrame solve this issue? If so, any sample code will be helpfull.
 
itrahul soni
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do easily this thing with servlet and always better for download and upload operations.
as you have told read the file from your server directory and with simple <a> hyperlink tag you can open the servlet in new window like
<a href="YoutServlet" target="_blank">Link to File</a>

and then in yourservlet by setting the response.setContentType and setHeader method you can tell the browser to open it inline(if the application program for opening the file inline is exists in the client system) or ask for the Open or Save dialogue using Content-Disposition as attachment,For that you have to properly set all the header and contentLength also.

 
dwarakanathan thiru
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have done that way and works well. Forgot to update this post. Thanks!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!