Apache FOP Servlet - How to change title?

Posted on 2004-08-26
Last Modified: 2013-11-24
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();

                //Setup a buffer to obtain the content length
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                //Setup Transformer
                Source xsltSrc = new StreamSource(new File( xslParam ));
                Transformer transformer = this.transformerFactory.newTransformer(xsltSrc);

                //Make sure the XSL transformation's result is piped through to FOP
                Result res = new SAXResult(driver.getContentHandler());

                //Setup input
                Source src = new StreamSource( new StringReader( xmlParam ) );

                //Start the transformation and rendering process
                transformer.transform(src, res);

                //Prepare response
                //Send content to Browser

Question by:blackfrancis75
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

pat5star earned 250 total points
ID: 11909575
Add the Content-Disposition header to the response.

//Prepare response
response.setHeader( "Content-Disposition", "attachment; filename=whatever.pdf" );



Author Comment

ID: 11909719
Adobe acrobat seems to ignore it if I change this to:
response.setHeader( "Content-Disposition", "inline; filename=whatever.pdf" );

do you know if this should be/ is supported?

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question