Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query about Request Forwarding

 
Ragav Baskaran
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

 
Ragav Baskaran
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic