This is the code that doesent work ----------------- snippet --------------------------
public void fileKlaarmaken(java.io.File file, int outputformaat,HttpServletResponse res) throws ServletException, IOException, FileNotFoundException { String fileName = file.getName(); ServletOutputStream out = res.getOutputStream(); if(outputformaat == be.vlaanderen.dov.prnlib.Renderer.RENDERER_HTML) res.setContentType( "text/html" ); else res.setContentType( "application/pdf" ); res.setContentLength((int) file.length()); res.setHeader("Content-Disposition","inline; filename="+fileName); returnFile(file, out); } public static void returnFile(java.io.File file, OutputStream out) throws FileNotFoundException, IOException { // A FileInputStream is for bytes FileInputStream fis = null; BufferedInputStream buffered = null; try { fis = new FileInputStream(file); buffered = new BufferedInputStream(fis); byte[] buf = new byte[4 * 1024]; // 4K buffer int bytesRead; while ((bytesRead = buffered.read(buf)) != -1) //while ((bytesRead = fis.read(buf)) != -1) { out.write(buf, 0, bytesRead); } } finally { if (fis != null) fis.close(); if (buffered != null) buffered.close(); } } Naam in html is altijpublic static void returnFile(java.io.File file, OutputStream out) throws FileNotFoundException, IOException { // A FileInputStream is for bytes FileInputStream fis = null; BufferedInputStream buffered = null; try { fis = new FileInputStream(file); buffered = new BufferedInputStream(fis); byte[] buf = new byte[4 * 1024]; // 4K buffer int bytesRead; while ((bytesRead = buffered.read(buf)) != -1) //while ((bytesRead = fis.read(buf)) != -1) { out.write(buf, 0, bytesRead); } } finally { if (fis != null) fis.close(); if (buffered != null) buffered.close(); } } ----------------- snippet -------------------------- For html files , the filename always becomes servletname.html .... For pdf's it becomes the last part of the url I ll try the web.xml solution as soon as i solve some other bugs Bruno Lowagie wrote: > Quoting "Cooremans, Rony" <[EMAIL PROTECTED]>: > > > >Define the name in the HTTP Header by > > >changing the "Content-Disposition". > > >This will probably work in most browsers, > > >but not in all. > > > > Doesent work in communicator 4.79 > > I'm 99% sure it works in Communicator 4.79. > I used it in the past (but I changed jobs so > I don't have the right code rightnow) > > > > > >Fool the browser by adding PathInfo to your URL. > > >If you designed your application following an MVC > > >architecture, you can play with the web.xml to > > >achieve this. > > > > What is an mvc architecture ? What do i have to do with web.xml ? ... > > Search Google for "Model View Controller" > > <?xml version="1.0" encoding="ISO-8859-1"?> > > <!DOCTYPE web-app > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd"> > > <web-app> > > <!-- Define servlet-mapped and path-mapped example filters --> > <filter> > <filter-name>PdfFilter</filter-name> > <filter-class>MyPdfFilter</filter-class> > </filter> > <filter-mapping> > <filter-name>PdfFilter</filter-name> > <url-pattern>*.pdf</url-pattern> > </filter-mapping> > > </web-app> > > If you have a webapp called myWebapp, all URLs like this: > http://www.myDomain.com/myWebapp/*.pdf > will point to class MyPdfFilter (implements Filter) > In this class, you create your PDF and send it to > the OutputStream... > > This is just one example, using filters. > Just play with the web.xml and you'll see there > are lots of other possibilities. _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions