Z
Zaphod
Hi All,
I have been pulling my hair out the past few days trying to get arrive at
a solution to my problem and no apis, docs or googling has helped yet. I
am using apache commons ftp to stream a file from the ftp server down to
a clients browser via a servlet. That part works great I'm happy to say.
The part I'm having a problem with is trying to display another page
(like a 'Thank you for downloading this file' after completion or an
error page once the file has been transfered (or failed).
How can I display another page once the transfer is complete? The
relevant code is below. Oh, the application server being used is
Broadvision 7.1.
I did read that you cannot have a getOutputStream and a getWriter in the
same servlet, but forwarding or redirecting to a new servlet/jsp page
does not seem to work. I have tried many different combinations of flush
(), flushBuffer(), reset(), resetBuffer(), flushToilet() on the
outputstream and on the response so far to no success.
I have a jsp that calls the servlet that does a database lookup to find
the file and validate the users input from the jsp page.
jsp code to call servlet:
RequestDispatcher rd = request.getRequestDispatcher("ReceiveServlet");
rd.forward(request,response);
Servlet code that
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=\"" +
db.getFileName() + "\"");
// Get the response object output stream
ServletOutputStream outs = response.getOutputStream();
// Initiate file retrieval
ftpConn.retrieveFile(fileName, outs);
ftpConn.logout(); ftpConn.disconnect();
outs.flush(); outs.close(); // tried with & without
// All works fine up to here...
//response.resetBuffer();
RequestDispatcher rd = request.getRequestDispatcher(nextPage);
rd.forward(request,response);
// also tried instead of forward, response.sendRedirect(nextPage);
Thanks for your help
Jon
I have been pulling my hair out the past few days trying to get arrive at
a solution to my problem and no apis, docs or googling has helped yet. I
am using apache commons ftp to stream a file from the ftp server down to
a clients browser via a servlet. That part works great I'm happy to say.
The part I'm having a problem with is trying to display another page
(like a 'Thank you for downloading this file' after completion or an
error page once the file has been transfered (or failed).
How can I display another page once the transfer is complete? The
relevant code is below. Oh, the application server being used is
Broadvision 7.1.
I did read that you cannot have a getOutputStream and a getWriter in the
same servlet, but forwarding or redirecting to a new servlet/jsp page
does not seem to work. I have tried many different combinations of flush
(), flushBuffer(), reset(), resetBuffer(), flushToilet() on the
outputstream and on the response so far to no success.
I have a jsp that calls the servlet that does a database lookup to find
the file and validate the users input from the jsp page.
jsp code to call servlet:
RequestDispatcher rd = request.getRequestDispatcher("ReceiveServlet");
rd.forward(request,response);
Servlet code that
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=\"" +
db.getFileName() + "\"");
// Get the response object output stream
ServletOutputStream outs = response.getOutputStream();
// Initiate file retrieval
ftpConn.retrieveFile(fileName, outs);
ftpConn.logout(); ftpConn.disconnect();
outs.flush(); outs.close(); // tried with & without
// All works fine up to here...
//response.resetBuffer();
RequestDispatcher rd = request.getRequestDispatcher(nextPage);
rd.forward(request,response);
// also tried instead of forward, response.sendRedirect(nextPage);
Thanks for your help
Jon