Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Redirecting after download a file

843836Aug 28 2003 — edited May 21 2008
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
<html>
<head> </head>
<body>
[Download]
</body>
</html>

FileDownload.jsp
<%@ page language="java" import="java.io.*, java.util.*" %>
<%
String filepath = "c:\\DIR-A\\";
String filename = "battleship.pdf";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
FileInputStream in = new FileInputStream(filepath + "\\" + filename);
int i;
while ((i=in.read()) != -1) {
out.write(i);
}
in.close();
out.close();
%>

I have tried to add response.sendRedirect("XXX.jsp"); after out.close(); but it doesn't work.

Thanks for suggestions.

cheers,
ypc
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2008
Added on Aug 28 2003
7 comments
2,059 views