-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Guilherme,
Guilherme Orioli wrote: | Didn't get it... it just doesn't work... what do I need to use instead of | the response.redirect ? These good folks are telling you to do something differently than you are currently doing it. Right now you are trying to: 1. generate your content 2. write the content to a file on the disk 3. redirect the user to the newly-generated file on disk Everyone is telling you to: 1. generate your content 2. write the content out to the ServletOutputStream directly ~ (not to System.out, nor to a FileOutputStream) No disk file; no redirect. Each request re-generates the content and sends it back to the client (browser) as the response to the original request. Let me lay it out for you. You currently have this code: | try{ | ServletOutputStream sos = response.getOutputStream(); | pdfStream.writeTo(sos); | System.out.println("pdsStream - "+pdfStream); | response.sendRedirect("myPDF.pdf"); | sos.flush(); | sos.close(); | pdfStream.close(); | pdfStream = null; | }catch(IOException e){ | e.printStackTrace(); | } | return ""; You should change it to: try{ ~ ServletOutputStream sos = response.getOutputStream(); ~ pdfStream.writeTo(sos); ~ sos.flush(); ~ sos.close(); ~ pdfStream.close(); } catch(IOException e) { ~ e.printStackTrace(); ~ response.sendError(HttpServletResponse.INTERNAL_SERVER_ERROR, ~ e.getMessage()); } return ""; /// ^^^ What is this? I'm not sure why your method returns a String. There's no reason for it to do so. Is this in a servlet? If it is, then you are going to run in to trouble with the "request" and "response" objects being members of the class. Two simultaneous requests will completely break your application. You can simplify the code somewhat, as well as reducing the amount of memory required to operate by eliminating your use of a ByteArrayOutputStream. The only downside is that your servlet will not be returning a Content-Length with the response (which isn't that big of a deal). - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkf030UACgkQ9CaO5/Lv0PAZUgCdFrgxEz2Ni1O7TTxcEWqvYyXN TzAAmwRB3Oau5Q4BMOr2/1YpamUXSyz+ =bmNA -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]