tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido Schoepp <gus-apa...@guxx.net>
Subject Re: A way to know if file download has ended
Date Sat, 03 Jun 2006 22:55:17 GMT
Bachler, Elisabeth (Elisabeth) schrieb:
> I have an application that uses tomcat 5.0.19. At one point in my
> application, the user has the possibility to click on a certain link in
> order to download a file.
> Once the file is downloaded, I would like the application to go to a certain
> jsp page.... is there a way to configure tomcat to do such a thing? I mean,
> to redirect to a page only if the download has been successfully ended?

Maybe this can work:
Write a a servlet (or JSP) that delivers the file to your user, e.g.

     response.setContentType("application/octet-stream"); //or whatever
     java.io.InputStream data =
         new java.io.FileInputStream("file.bin");
     byte[] buf = new byte[4 * 1024];
     int len;
     while ((len = data.read(buf, 0, buf.length)) != -1) {
         sout.write(buf, 0, len);
     }

After that you can forward to the desired page:
     RequestDispatcher dispatcher =
         getServletContext().getRequestDispatcher("fwd.jsp");
     dispatcher.forward(request, response);


Guido

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message