blackfrancis75
asked on
Apache FOP Servlet - How to change title?
Hi Experts,
I have a basic FOP Servlet which works well, except that when I try to save the PDF that's generated the filename is always 'FOPServlet.pdf'
This name is being read from the browser window title, so my question is; can someone tell me how to change the title of the browser window?
Note that I can't use:
PrintWriter out = response.getWriter();
out.println("<html><head>< title>My Title</title></head>\n");
As I normally would for a servlet window title, because of the FOP processing element.
Here is the FOP servlet code:
Driver driver = new Driver();
driver.setLogger(this.log) ;
driver.setRenderer(Driver. RENDER_PDF );
//Setup a buffer to obtain the content length
ByteArrayOutputStream out = new ByteArrayOutputStream();
driver.setOutputStream(out );
//Setup Transformer
Source xsltSrc = new StreamSource(new File( xslParam ));
Transformer transformer = this.transformerFactory.ne wTransform er(xsltSrc );
//Make sure the XSL transformation's result is piped through to FOP
Result res = new SAXResult(driver.getConten tHandler() );
//Setup input
Source src = new StreamSource( new StringReader( xmlParam ) );
//Start the transformation and rendering process
transformer.transform(src, res);
//Prepare response
response.setContentType("a pplication /pdf");
response.setContentLength( out.size() );
//Send content to Browser
response.getOutputStream() .write(out .toByteArr ay());
response.getOutputStream() .flush();
I have a basic FOP Servlet which works well, except that when I try to save the PDF that's generated the filename is always 'FOPServlet.pdf'
This name is being read from the browser window title, so my question is; can someone tell me how to change the title of the browser window?
Note that I can't use:
PrintWriter out = response.getWriter();
out.println("<html><head><
As I normally would for a servlet window title, because of the FOP processing element.
Here is the FOP servlet code:
Driver driver = new Driver();
driver.setLogger(this.log)
driver.setRenderer(Driver.
//Setup a buffer to obtain the content length
ByteArrayOutputStream out = new ByteArrayOutputStream();
driver.setOutputStream(out
//Setup Transformer
Source xsltSrc = new StreamSource(new File( xslParam ));
Transformer transformer = this.transformerFactory.ne
//Make sure the XSL transformation's result is piped through to FOP
Result res = new SAXResult(driver.getConten
//Setup input
Source src = new StreamSource( new StringReader( xmlParam ) );
//Start the transformation and rendering process
transformer.transform(src,
//Prepare response
response.setContentType("a
response.setContentLength(
//Send content to Browser
response.getOutputStream()
response.getOutputStream()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
response.setHeader( "Content-Disposition", "inline; filename=whatever.pdf" );
do you know if this should be/ is supported?