DLESE Tools
v1.6.0

org.dlese.dpc.webapps.servlets.filters
Class FilterCore

java.lang.Object
  extended by org.dlese.dpc.webapps.servlets.filters.FilterCore
All Implemented Interfaces:
Filter
Direct Known Subclasses:
GzipFilter, JavaScriptWritelnFilter, XMLPostProcessingFilter, XMLValidationFilter

public abstract class FilterCore
extends Object
implements Filter

Abstract class that contains core methods common to Servlet Filters. Implementation note: Servlet Filters only get instatiated once and live for the lifetime of the application.

Version:
$Id: FilterCore.java,v 1.2 2009/03/20 23:34:01 jweather Exp $
Author:
John Weatherley

Constructor Summary
FilterCore()
           
 
Method Summary
protected static String getDateStamp()
          Return a string for the current time and date, sutiable for display in log files and output to standout:
protected  boolean handleErrorCodes(HttpServletResponse res, CharArrayWrapper wrapper)
          Handles http errors (not yet implemented).
static boolean isGzipSupported(HttpServletRequest req)
          Determines whether the client that made the request can accept a gzip response.
protected  void prtlnCore(String s)
          Output a line of text to standard out, with datestamp, if debug is set to true.
protected  void writeGzipResponse(char[] content, HttpServletResponse res)
          Writes the response content to the client using gzip compression.
protected  void writeRegularResponse(StringBuffer content, HttpServletResponse res)
          Writes the response to the OutputStream without gzipping it, for use if the client can not accept a gzip response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Constructor Detail

FilterCore

public FilterCore()
Method Detail

writeGzipResponse

protected final void writeGzipResponse(char[] content,
                                       HttpServletResponse res)
                                throws IOException
Writes the response content to the client using gzip compression. Before using this method, make sure the client can accespt gzip content via the isGzipSupported(javax.servlet.http.HttpServletRequest) method.

Note: you must set the content encoding type to gzip using the method
response.setHeader("Content-Encoding", "gzip"); prior to calling chain.doFilter() method.

Parameters:
content - The content to sent to the client in gzip format
res - The response object
Throws:
IOException - If IO Error occurs

writeRegularResponse

protected final void writeRegularResponse(StringBuffer content,
                                          HttpServletResponse res)
                                   throws IOException
Writes the response to the OutputStream without gzipping it, for use if the client can not accept a gzip response.

Parameters:
content - The content to setd
res - The response
Throws:
IOException - If error

isGzipSupported

public static final boolean isGzipSupported(HttpServletRequest req)
Determines whether the client that made the request can accept a gzip response.

Parameters:
req - The request
Returns:
True if the client can accept gzip content

handleErrorCodes

protected final boolean handleErrorCodes(HttpServletResponse res,
                                         CharArrayWrapper wrapper)
                                  throws IOException
Handles http errors (not yet implemented).

Parameters:
res - The response
wrapper - The wrapper
Returns:
True if an http error occured and is being handled here
Throws:
IOException - If error processing

getDateStamp

protected static final String getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout:

Returns:
The dateStamp value

prtlnCore

protected final void prtlnCore(String s)
Output a line of text to standard out, with datestamp, if debug is set to true.

Parameters:
s - The String that will be output.

DLESE Tools
v1.6.0