# HG changeset patch # User cmielack # Date 1234368168 -3600 # Node ID 86b5589f38db08b3230edb894fbf0609e2a880f8 # Parent 85772b4cd7600e28ae70c10aced92ad975746eba added a sendRedirect after the creation of a PDF so that the user that requested the document gets to download it upon completion diff -r 85772b4cd760 -r 86b5589f38db servlet/src/digilib/servlet/PDFCache.java --- a/servlet/src/digilib/servlet/PDFCache.java Wed Feb 11 16:47:28 2009 +0100 +++ b/servlet/src/digilib/servlet/PDFCache.java Wed Feb 11 17:02:48 2009 +0100 @@ -103,6 +103,7 @@ // ... and if the file already exists, send it ... try { sendFile(request,response); + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -122,13 +123,17 @@ else if (status == STATUS_NONEXISTENT){ // ... or else, generate the file and inform the user about the estimated generation-time try { - this.createFile(request, response); + createFile(request, response); + response.sendRedirect(request.getRequestURI()+'?'+request.getQueryString()); // refresh the browser after finishing the file } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } else { @@ -195,7 +200,7 @@ } } - public void createFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ + public void createFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InterruptedException{ // use MakePDF to generate a new Document and put it into the cache-directory // get global instance of MakePDF @@ -213,6 +218,7 @@ mpdf.doCreate(request,response,filename); // set the parameters and ... mpdf.run(); // ... start generating the pdf + //new Thread(mpdf,"MakePDF").start(); } } \ No newline at end of file