Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

File download and request Forward

 
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\";");
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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 VI Editor Redhat
  • 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.
    Bookmark Topic Watch Topic
  • New Topic