I'm having a problem with tomcat 6 and redirection. My servlet creates a class that generates a file on the tomcat server. At the end of the servlet's post method I call the redirect method so that the user can download this file. The user is redirected and prompted to download the file. The problem is the file is stale. It's the file that was there before I started the tomcat server. I even tried sleeping the thread before the redirection. Any ideas why they are being redirected to this stale file that no longer exists?
I'm using eclipse to start a tomcat server.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String outputName = "XXX\\workspace\\BlahOnline\\WebContent\\Blah.xlsm";
String redirect = "Blah.xlsm";
response.sendRedirect(redirect);
}
Edit: Nevermind, I found a better way to download the file using code in the servlet. This thread helped a lot: Download mp3 file from Tomcat server with Java servlet