Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.faceless.report
Class PDFProxyServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              org.faceless.util.HttpProxyServlet
                  org.faceless.report.PDFProxyServlet

All Implemented Interfaces:
  Serializable, Servlet, ServletConfig, ErrorHandler

    public abstract class PDFProxyServlet

extends org.faceless.util.HttpProxyServlet
implements ErrorHandler

The PDFProxyServlet is a basic servlet which accepts a request, reads an XML report from another URL and turns it into a PDF to be returned to the client. Those using the Servlet 2.3 architecture may want to consider using the `PDFFilter` class instead.

Most overriders should be able to just override the `getProxyURL()` method, to alter where the report XML is kept.

Meta tags that aren't already known to the Report Generator and that begin with "`HTTP-`" are added to the response header (minus the "HTTP-" prefix). An example would be to place `<meta name="HTTP-Expires" value="Mon, 01 Jan 1999 12:00:00 GMT">` in the head of the XML, which would set the "Expires" header in the HTTP response.

The following custom Meta-Tags may also be used to control the behaviour of the servlet.

- `Servlet-Cache` - set the length of time to cache the generated PDF. The cache is actually implemented in the ProxyServlet, and is completely independent of any external caches between the server and the client. Examples of valid values are "1h30m", to cache the document for 1.5 hours, "45s" to cache for 45 seconds or "1d" to cache for 1 day. Any combination of days, hours, minutes and seconds is valid. There is no way to flush this document from the client browser.
- `Servlet-FileName` - ask the client browser to save the file as the specified filename instead of displaying it inline. This uses the `Content-Disposition` header, which in theory is accepted by NS4+ and IE5+. On our test system at least however, this didn't work, and in IE5.5 actually prevented us from viewing the document at all! Use with caution.

Some initialization parameters can be set in the `web.xml` file to further control various internal aspects of the servlet:

- `org.xml.sax.driver` - may be set to the base class of your SAX parsers `XMLReader` implementation, if the generator is unable to locate it.
- `org.faceless.util.proxytimeout` - may be set to the number of milliseconds to wait for a response from the proxy request. Defaults to 15000, or 15 seconds.

This class also implements `org.xml.sax.ErrorHandler`, to deal with any errors found during the XML parsing process. Currently all warnings and errors are fatal, and logged to `System.err`.

See Also:
  Serialized Form

Constructor Summary
`PDFProxyServlet()`

Method Summary
`void` | `error(SAXParseException exception)`
`void` | `fatalError(SAXParseException exception)`
`abstract String` | `getProxyURL(HttpServletRequest request, HttpServletResponse response)` Returns the absolute URL to send the proxy request to.
`org.faceless.util.HttpRequestWriter` | `getRequest(org.faceless.util.HttpRequestReader request, HttpServletResponse response)` Implements the `getRequest` method of the generic `HttpProxyServlet`.
`org.faceless.util.HttpResponseWriter` | `getResponse(org.faceless.util.HttpResponseReader in)` Implements the `getResponse` method of the generic `HttpProxyServlet`.
`void` | `init()`
`void` | `initParser(ReportParser parser)` Set any initialization options for the parser, if necessary.
`void` | `metaTag(org.faceless.util.HttpResponseReader reader, org.faceless.util.HttpResponseWriter writer, String name, String value)` Handle any meta tags that aren't recognised by the core Report Generator.
`void` | `modifyPDF(PDF pdf)` Adjust the PDF after it's been created but before it's rendered back to the browser.
`void` | `warning(SAXParseException exception)`

Methods inherited from class org.faceless.util.HttpProxyServlet
`doGet, doPost`

Methods inherited from class javax.servlet.http.HttpServlet
`service`

Methods inherited from class javax.servlet.GenericServlet
`destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PDFProxyServlet

    public PDFProxyServlet()

Method Detail

### init

    public void init()
              throws ServletException

  Overrides:
    `init` in class `org.faceless.util.HttpProxyServlet`
  Throws:
    `ServletException`

### getRequest

    public org.faceless.util.HttpRequestWriter getRequest(org.faceless.util.HttpRequestReader request,
                                                          HttpServletResponse response)
                                                   throws ServletException,
                                                          IOException

  Implements the `getRequest` method of the generic `HttpProxyServlet`. Subclasses should be able to leave this method untouched.

  Specified by:
    `getRequest` in class `org.faceless.util.HttpProxyServlet`
  Parameters:
    `request` - the incoming request to this proxy
    `response` - the outgoing response. Should only be written to if this method is returning `null` due to an error.
  Returns:
    the request that this proxy should pass on.
  Throws:
    `ServletException`
    `IOException`

### getResponse

    public org.faceless.util.HttpResponseWriter getResponse(org.faceless.util.HttpResponseReader in)
                                                     throws ServletException,
                                                            IOException

  Implements the `getResponse` method of the generic `HttpProxyServlet`. Subclasses should be able to leave this method untouched.

  Specified by:
    `getResponse` in class `org.faceless.util.HttpProxyServlet`
  Parameters:
    `in` - the response from the request specified by `getRequest()`
  Returns:
    the response that this proxy should pass on
  Throws:
    `ServletException`
    `IOException`

### metaTag

    public void metaTag(org.faceless.util.HttpResponseReader reader,
                        org.faceless.util.HttpResponseWriter writer,
                        String name,
                        String value)
                 throws ServletException,
                        IOException

  Handle any meta tags that aren't recognised by the core Report Generator. This method recognises tags begining with `HTTP-`, as well as `Servlet-FileName` and `Servlet-Cache`.

  Parameters:
    `request` - the Servlet request
    `response` - the Servlet request
    `name` - the "name" attribute from the meta tag
    `value` - the "value" attribute from the meta tag
  Throws:
    `ServletException`
    `IOException`

### warning

    public void warning(SAXParseException exception)
                 throws SAXException

  Specified by:
    `warning` in interface `ErrorHandler`
  Throws:
    `SAXException`

### error

    public void error(SAXParseException exception)
               throws SAXException

  Specified by:
    `error` in interface `ErrorHandler`
  Throws:
    `SAXException`

### fatalError

    public void fatalError(SAXParseException exception)
                    throws SAXException

  Specified by:
    `fatalError` in interface `ErrorHandler`
  Throws:
    `SAXException`

### initParser

    public void initParser(ReportParser parser)

  Set any initialization options for the parser, if necessary. Overriders may optionally use this method to set parser flags (by default, this method does nothing).

  Since:
    1.0.4

### modifyPDF

    public void modifyPDF(PDF pdf)

  Adjust the PDF after it's been created but before it's rendered back to the browser. Subclassers who need to alter the PDF in some way should override this method and make any changes they need to make to the PDF there.

  Since:
    1.1.27

### getProxyURL

    public abstract String getProxyURL(HttpServletRequest request,
                                       HttpServletResponse response)
                                throws IOException,
                                       ServletException

  Returns the absolute URL to send the proxy request to. This method is the only method that needs to be overriden by concrete subclasses of this class.

  If no valid URL can be constructed due to an incorrect request, this method should return `null` and an appropriate error written to the `response`.

  Parameters:
    `request` - the incoming request from the client
    `response` - the outgoing response to the client - should only be written to if an error has occurred and the method is returning null
  Returns:
    the absolute URL to proxy the request to, or `null` if an error has occurred and no request should be made.
  Throws:
    `IOException`
    `ServletException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Big Faceless Organization