• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File download and request Forward

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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\";");
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic