• Post Reply Bookmark Topic Watch Topic
  • New Topic

Redirecting after download a file  RSS feed

 
chiu pong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I want to ask a question about redirecting. I have a link in the test1.jsp to download a file. After I download the file, I want to redirect the user to a page to notify the user. How can I do that?
Below are the original codes i have now:
Test1.jsp

FileDownload.jsp

I have tried to add response.sendRedirect("XXX.jsp"); after out.close(); but it doesn't work.
Thanks for suggestions.
cheers,
ypc
[ August 28, 2003: Message edited by: chiu pong ]
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you cannot.
Your JSP (actually the servlet) is just writing a stream of data that gets sent to your browser. Your browser does something with that stream, either displaying it, or saving it as a file on your local file system, or passing it to some helper app to use. But once the server has sent the file, there is no further transaction possible with the browser, until the browser makes a request.
What you could do is return a page that auto-refreshes itself, and on the refresh (the second time it's processed) you can send your file stream. That way, you end up with your second page, and you get your file sent over as well.
But you can't both send a file, and then re-direct the browser to another page at the same time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!