Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/PDFCache.java @ 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 |
comparison
equal
deleted
inserted
replaced
497:85772b4cd760 | 498:86b5589f38db |
---|---|
101 | 101 |
102 if (status == STATUS_DONE) { | 102 if (status == STATUS_DONE) { |
103 // ... and if the file already exists, send it ... | 103 // ... and if the file already exists, send it ... |
104 try { | 104 try { |
105 sendFile(request,response); | 105 sendFile(request,response); |
106 | |
106 } catch (IOException e) { | 107 } catch (IOException e) { |
107 // TODO Auto-generated catch block | 108 // TODO Auto-generated catch block |
108 e.printStackTrace(); | 109 e.printStackTrace(); |
109 } | 110 } |
110 } | 111 } |
120 } | 121 } |
121 } | 122 } |
122 else if (status == STATUS_NONEXISTENT){ | 123 else if (status == STATUS_NONEXISTENT){ |
123 // ... or else, generate the file and inform the user about the estimated generation-time | 124 // ... or else, generate the file and inform the user about the estimated generation-time |
124 try { | 125 try { |
125 this.createFile(request, response); | 126 createFile(request, response); |
127 response.sendRedirect(request.getRequestURI()+'?'+request.getQueryString()); // refresh the browser after finishing the file | |
126 } catch (ServletException e) { | 128 } catch (ServletException e) { |
127 // TODO Auto-generated catch block | 129 // TODO Auto-generated catch block |
128 e.printStackTrace(); | 130 e.printStackTrace(); |
129 } catch (IOException e) { | 131 } catch (IOException e) { |
132 // TODO Auto-generated catch block | |
133 e.printStackTrace(); | |
134 } catch (InterruptedException e) { | |
130 // TODO Auto-generated catch block | 135 // TODO Auto-generated catch block |
131 e.printStackTrace(); | 136 e.printStackTrace(); |
132 } | 137 } |
133 } | 138 } |
134 else { | 139 else { |
193 if (sos != null) | 198 if (sos != null) |
194 sos.close(); | 199 sos.close(); |
195 } | 200 } |
196 } | 201 } |
197 | 202 |
198 public void createFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ | 203 public void createFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InterruptedException{ |
199 // use MakePDF to generate a new Document and put it into the cache-directory | 204 // use MakePDF to generate a new Document and put it into the cache-directory |
200 | 205 |
201 // get global instance of MakePDF | 206 // get global instance of MakePDF |
202 MakePDF mpdf = (MakePDF) this.getServletContext().getAttribute("digilib.servlet.MakePDF"); | 207 MakePDF mpdf = (MakePDF) this.getServletContext().getAttribute("digilib.servlet.MakePDF"); |
203 | 208 |
211 | 216 |
212 logger.debug("createFile is going to create file "+filename); | 217 logger.debug("createFile is going to create file "+filename); |
213 | 218 |
214 mpdf.doCreate(request,response,filename); // set the parameters and ... | 219 mpdf.doCreate(request,response,filename); // set the parameters and ... |
215 mpdf.run(); // ... start generating the pdf | 220 mpdf.run(); // ... start generating the pdf |
221 | |
216 //new Thread(mpdf,"MakePDF").start(); | 222 //new Thread(mpdf,"MakePDF").start(); |
217 } | 223 } |
218 } | 224 } |