File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HTTP Servlet Response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Servlet Response " Watch "HTTP Servlet Response " New topic

HTTP Servlet Response

Ram Thirumangalam

Joined: Aug 28, 2003
Posts: 20
I have a question regarding the Servlet Response. First, let me make clear that I am a novice to JAVA as well as Servelt programming. So Please bear with any questions that seem to be silly.
Now, Here is the main issue. Upon executing a servlet, the current code creates a PDF document dynamically on the fly from data that I receive from my host and writes it out to a new browser window using the servletoutput stream (response.setContentType("application/pdf")).
Now, I wish to create two frames in the new browser window and want the PDF document to be opened in one of the frame while putting some text messages in the other frame. So is it possible to direct the PDF output to the specific frame? If so please let me know.
Any help would be greatly appreciated.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Hi Ram, welcome to the Ranch where beginnner questions are more than welcome!
But no, it is not possible from the response to direct where the response will go. It will always be delivered to the window/frame in which the request was made.
How I would approach this is to back up and make it so that whatever triggerred the action in the first place causes two requests: one into the frame in which you want the text, and one to get the PDF into its own frame. You'll probably need some Javascript to cause a single action (button push?) to trigger the two separate requests.
If so, this is a great question for the HTML/Javascript forum.
[ August 28, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Ram Thirumangalam

Joined: Aug 28, 2003
Posts: 20
Hello Bear
Thank you very much for the information. I have been trying hgard to find out if it is feasible.
So you mean that I need to execute two servlets (one for PDF and another for Text for the respecive frame) for the actions that occur for a single push (say button click). I will post any messages in the javascript forum if I have further questions regardign this.
Will try this suggestion and let u know
maneesh subherwal
Ranch Hand

Joined: Aug 26, 2002
Posts: 42
I think how you could do this is have a dummy servlet to only open the frames window sending information that it needs to generate the pdf.
Next, onloading the frame browser window, call the pdfservlet from one frame and either write out your text in the other frame, if static or use another servlet.
I hope this helps...
request --> dummyServlet --> open new browser with two empty frames
in frame 1 use javascript onLoad --> call pdfServlet
in frame 2 use javascript onLoad --> call textServlet
Therefore you would need 3 servlets.
Thank you,

Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
Ram Thirumangalam

Joined: Aug 28, 2003
Posts: 20
Thank you guys. It was really helpful and now I am able to make it work.
I agree. Here's the link:
subject: HTTP Servlet Response
It's not a secret anymore!