Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File download and request Forward

 
Subha Garg
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I want to send a file to browser and then want to send control to another jsp.
i am sending a file to browser through following command which is opening in a new window.after that i want to forward the page to a jsp how can i do it

response.setContentType("application/doc");
response.setHeader("Content-Disposition", "attachment;filename=\""+ "FullElementReport"+ ".doc\";");
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only have one response per request.
You can't do both.
 
Subha Garg
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What other alternative do i have for the following situation:



on file1.jsp

i have a button with caption download file

on the click of the button request is submitted to downloadfile.java servlet

downloadfile.java servlet sends doc file to browser by opening separate (open ,save as) dialog box

during this event my file1.jsp is visible in its own window on client side while client gets an (open saveAs) popup dialog for doc file.

i want my downloadfile.java servlet to send the download file to servlet (which it is doing perfectally well) and also refresh the file1.jsp which i cannot do because servlet cannot send two responses?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I've done this case is turn it around.

I have the link point to the second JSP.
In the second JSP, I have a hidden iframe that has makes a request for the download file in its onload event.

One caveat: Some of our customers have started having trouble with this in MSIE6 when running without SSL, after one of the Windows updates installed a popup blocker that doesn't allow new windows to be opened from the onload event (even when the popup blocker is shut off). Our app always runs under SSL in production so I haven't had to find a solution for it but, if I had to, I would try using a refresh header instead of JavaScript from the onload event.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic