PAJES 2.3.9

org.pajes.servlet
Class StaticPajeServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.pajes.servlet.PajeServlet
              extended byorg.pajes.servlet.StaticPajeServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
DefaultStyleSheet, InputDateIcon, InputDateStyleSheet, TreeImage, TreeScript, TreeStyleSheet, ValidationScript

public abstract class StaticPajeServlet
extends PajeServlet

Abstract super-class of classes that return static content that the web server would not usually have access to (for example, static content located within a JAR in the /WEB-INF/lib directory).

See Also:
Serialized Form

Constructor Summary
protected StaticPajeServlet()
          Creates a new StaticPajeServlet.
protected StaticPajeServlet(java.lang.String contentType)
          Creates a new StaticPajeServlet.
 
Method Summary
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Sends the requested static content to the browser.
protected abstract  byte[] getContent(javax.servlet.http.HttpServletRequest request)
          Retrieves the static content to be returned to a request.
protected  java.lang.String getContentType(java.lang.String filename, javax.servlet.http.HttpServletRequest request)
          Retrieves the MIME type of the content to be returned.
protected  long getExpirationDate(javax.servlet.http.HttpServletRequest request)
          Retrieves the expiration date of this content.
protected  java.lang.String getFilename(javax.servlet.http.HttpServletRequest request)
          Retrieves the suggested name of the attachment to be returned to the request.
protected  long getLastModified(javax.servlet.http.HttpServletRequest request)
          Returns the time the content was last modified, in milliseconds since midnight January 1, 1970 GMT.
protected  void setHeaders(Browser browser)
          Enables sub-classes to specify any additional headers prior to the content being written to the browser.
 
Methods inherited from class org.pajes.servlet.PajeServlet
createPaje, createPaje, createPaje, doPost, getAbsoluteHREF, getBaseHREF, getMaxFileUploadSize, getPajeFactory, getResource, getUploadedFile, getUploadedFileNames, handleException, init, log, log, service, setInputFieldsFromRequestAttributes, setInputFieldsFromRequestParameters, setMaxFileUploadSize, setPajeFactory
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticPajeServlet

protected StaticPajeServlet()
Creates a new StaticPajeServlet.


StaticPajeServlet

protected StaticPajeServlet(java.lang.String contentType)
Creates a new StaticPajeServlet.

Parameters:
contentType - the default type of the static content to be returned.
Method Detail

getContent

protected abstract byte[] getContent(javax.servlet.http.HttpServletRequest request)
                              throws java.io.IOException
Retrieves the static content to be returned to a request.

Parameters:
request - the request object.
Returns:
the byte array of the content this servlet will return.
Throws:
java.io.IOException

getContentType

protected java.lang.String getContentType(java.lang.String filename,
                                          javax.servlet.http.HttpServletRequest request)
                                   throws java.io.IOException
Retrieves the MIME type of the content to be returned. If a content type was set on the constructor, that value will always be returned. If no content type was defined on the constructor, and getFilename(javax.servlet.http.HttpServletRequest) returns null or a name from which the MIME type cannot be determined, a default of text/plain will be used.

Sub-classes may over-ride this method to dynamically determine the MIME type.

Parameters:
filename - the value returned by getFilename(javax.servlet.http.HttpServletRequest).
request - the request object.
Returns:
the MIME content type.
Throws:
java.io.IOException - if an I/O error occurs.

getExpirationDate

protected long getExpirationDate(javax.servlet.http.HttpServletRequest request)
Retrieves the expiration date of this content. The default expiration date is 24 hours from the time of the request.

Sub-classes may over-ride this method to return a different expiration date.

Parameters:
request - the request object.
Returns:
the time the content will expire, in milliseconds since midnight January 1, 1970 GMT, or -1 if the content is to expire immediately.

getFilename

protected java.lang.String getFilename(javax.servlet.http.HttpServletRequest request)
                                throws java.io.IOException
Retrieves the suggested name of the attachment to be returned to the request.

Sub-classes may over-ride this method to return a file name specific to the attachment. The default implementation returns null, which means that the content will be returned to the browser WITHOUT a CONTENT-DISPOSITION header indicating that the content is an attachment and suggesting a default file name.

Parameters:
request - the request object.
Returns:
the name that will be suggested to the browser.
Throws:
java.io.IOException - if an I/O error occurs.

setHeaders

protected void setHeaders(Browser browser)
Enables sub-classes to specify any additional headers prior to the content being written to the browser. The default implementation does nothing.

By default, the following items are already set prior to invoking this method:

The content type specified on the constructor and the content length (determined from getContent(javax.servlet.http.HttpServletRequest)) have alos been set on the response.

Parameters:
browser - the Browser object.

getLastModified

protected long getLastModified(javax.servlet.http.HttpServletRequest request)
Returns the time the content was last modified, in milliseconds since midnight January 1, 1970 GMT. The default is the instantiation time of the servlet.

Parameters:
request - the HttpServletRequest object that is sent to the servlet
Returns:
a long integer specifying the time the HttpServletRequest object was last modified, in milliseconds since midnight, January 1, 1970 GMT, or -1 if the time is not known

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Sends the requested static content to the browser.

Overrides:
doGet in class PajeServlet
Parameters:
request - the request object.
response - the response object.
Throws:
javax.servlet.ServletException - if the request could not be handled.
java.io.IOException - if an input or output error is detected when the servlet handles the request.

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.