Mercurial > hg > digilib-old
changeset 498:86b5589f38db
added a sendRedirect after the creation of a PDF so that the user that requested the document gets to download it upon completion
author | cmielack |
---|---|
date | Wed, 11 Feb 2009 17:02:48 +0100 |
parents | 85772b4cd760 |
children | 87d2ed21bdec |
files | servlet/src/digilib/servlet/PDFCache.java |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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