org.foray.demo.servlet
Class AbstractDemoServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.foray.demo.servlet.AbstractDemoServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
DemoPrintServlet, DemoServlet

public abstract class AbstractDemoServlet
extends javax.servlet.http.HttpServlet

Abstract base class for FOray demo servlets.

See Also:
Serialized Form

Field Summary
static String FO_REQUEST_PARAM
          Constant for the "fo" request parameter.
static String XML_REQUEST_PARAM
          Constant for the "xml" request parameter.
static String XSL_REQUEST_PARAM
          Constant for the "xsl" request parameter.
 
Constructor Summary
AbstractDemoServlet()
          Constructor.
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected abstract  String getContentType()
          Return the content type.
 org.apache.commons.logging.Log getLogger()
          Returns the logger.
protected abstract  OutputTargetType getRendererType()
          Return the renderer type.
 void renderFO(InputSource inputHandler, javax.servlet.http.HttpServletResponse response)
          Renders an FO inputsource into a PDF file which is written directly to the response object's OutputStream.
 void renderXML(File xmlFile, File xslFile, javax.servlet.http.HttpServletResponse response)
          Renders an XML file into a PDF file by applying a stylesheet that converts the XML to XSL:FO.
protected  FOrayDocument setupJAXPDocument(File xmlFile, File xslFile, FOraySession session)
          Creates the FOrayDocument using JAXP.
protected  FOrayDocument setupSAXDocument(FOraySession session, InputSource inputSource)
          Creates the FOrayDocument using normal SAX processing.
protected  FOraySession setupSession(javax.servlet.http.HttpServletResponse response)
          Creates the FOraySession.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FO_REQUEST_PARAM

public static final String FO_REQUEST_PARAM
Constant for the "fo" request parameter.

See Also:
Constant Field Values

XML_REQUEST_PARAM

public static final String XML_REQUEST_PARAM
Constant for the "xml" request parameter.

See Also:
Constant Field Values

XSL_REQUEST_PARAM

public static final String XSL_REQUEST_PARAM
Constant for the "xsl" request parameter.

See Also:
Constant Field Values
Constructor Detail

AbstractDemoServlet

public AbstractDemoServlet()
Constructor.

Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException

getContentType

protected abstract String getContentType()
Return the content type.

Returns:
The content type.

getRendererType

protected abstract OutputTargetType getRendererType()
Return the renderer type.

Returns:
The renderer type.

setupSession

protected FOraySession setupSession(javax.servlet.http.HttpServletResponse response)
                             throws FOrayException
Creates the FOraySession.

Parameters:
response - The servlet response.
Returns:
A FOraySession.
Throws:
FOrayException - For errors creating the session.

setupSAXDocument

protected FOrayDocument setupSAXDocument(FOraySession session,
                                         InputSource inputSource)
                                  throws FOrayException
Creates the FOrayDocument using normal SAX processing.

Parameters:
session - The parent FOraySession.
inputSource - The input source to be processed.
Returns:
A FOrayDocument to be used in processing.
Throws:
FOrayException - For errors creating the document.

setupJAXPDocument

protected FOrayDocument setupJAXPDocument(File xmlFile,
                                          File xslFile,
                                          FOraySession session)
                                   throws TransformerConfigurationException,
                                          FOrayException
Creates the FOrayDocument using JAXP.

Parameters:
xmlFile - The xml file to be processed.
xslFile - The stylesheet file to be processed.
session - The parent FOraySession.
Returns:
A FOrayDocument to be used in processing.
Throws:
TransformerConfigurationException - For errors configuring the transformer.
FOrayException - For errors creating the document.

renderFO

public void renderFO(InputSource inputHandler,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException
Renders an FO inputsource into a PDF file which is written directly to the response object's OutputStream.

Parameters:
inputHandler - A SAX input handler.
response - The Servlet response.
Throws:
javax.servlet.ServletException - For exceptions during processing.

renderXML

public void renderXML(File xmlFile,
                      File xslFile,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException
Renders an XML file into a PDF file by applying a stylesheet that converts the XML to XSL:FO. The PDF is written directly to the response object's OutputStream.

Parameters:
xmlFile - The semantic XML file to be transformed.
xslFile - The stylesheet to be applied to xmlFile.
response - The HTTP servlet response.
Throws:
javax.servlet.ServletException - For errors during processing.

getLogger

public org.apache.commons.logging.Log getLogger()
Returns the logger.

Returns:
The logger.


Copyright © 2017. All rights reserved.