org.faceless.report
Class PDFProxyServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.faceless.util.HttpProxyServlet
              extended by 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.

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

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


Copyright © 2001-2012 Big Faceless Organization