aspose file tools*
The moose likes Servlets and the fly likes Query about Request Forwarding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Query about Request Forwarding" Watch "Query about Request Forwarding" New topic
Author

Query about Request Forwarding

Ragav Baskaran
Ranch Hand

Joined: Nov 04, 2007
Posts: 36
Hi,

I have a requirement where the user will fill some information in a HTML page and upon page submit, it sends the entered information to a Servlet through "POST" method.

Now in the Servlet i have a business logic where it creates a file, based on the inputs from the page.

After this i want to open up a seperate browser/popup to display the content of the file which i newly created.

I'm able to do this in the same browser. But my requirement is to open it up in a seperate(new) browser/popup.

Thanks,
Raga
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Set the target for the form to a blank window (new window every time form is submitted), or a window with a name (submissions go to the same window if it is left open).



Steve
Ragav Baskaran
Ranch Hand

Joined: Nov 04, 2007
Posts: 36
Hi Steve,
Thanks for your inputs.

Though the solution given by you works, but it won't fit to my requirement as a whole, because in my case i'm doing a validation (of the input given in the form) in my servlet and then based on the validation result i may have to decide either to open a new window(if validation is successful) or else display an error message in the old window itself with out opening the new window.

Is there any way, where we can instruct the browser to do this based on the servlet response ??

Thanks,
Ragavendra
[ August 03, 2008: Message edited by: Raga Vendran ]
anubechara Gupta
Greenhorn

Joined: Jul 05, 2006
Posts: 17
I think you can set some flag in the request object and based on this flag you can execute javascript in your target page to open new window.
eg. If your form data is validated set value of "validationFlag" in request object as "true" and on page load use java script to open new window if flag is true.
<%if(request.getAttribute("validationFlag").toString().equals("true"))%>
<script>
window.open ("outputfile.txt","mywindow");
</script>
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

Have you read the book Java Servlet Programming By Jason Hunter(Oreilly). In the 6th chapter it uses it's custom library to send a multi-part response. It's fairly simple. I think you should try it...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query about Request Forwarding