atg.servlet.pagefilter
Class PageFilterUtil

java.lang.Object
  extended by atg.servlet.pagefilter.PageFilterUtil

public class PageFilterUtil
extends java.lang.Object


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Method Summary
static void encodeHTMLFile(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, java.lang.String pFilename, java.lang.String pSrcEncoding, boolean pCacheData)
          Takes the file name specified, parses it and encodes all URLs it found using the request.encodeURL method.
static void writeFile(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, java.lang.String pFilename, java.lang.String pSrcEncoding, boolean pCacheData)
          This method will write a file to the response supplied.
static void writeHTMLFile(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, java.lang.String pFilename, java.lang.String pSrcEncoding, boolean pCacheData, boolean pSetContentType)
          Takes the name of an HTML file and writes its content to the response supplied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Method Detail

writeHTMLFile

public static void writeHTMLFile(DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse,
                                 java.lang.String pFilename,
                                 java.lang.String pSrcEncoding,
                                 boolean pCacheData,
                                 boolean pSetContentType)
                          throws java.io.IOException
Takes the name of an HTML file and writes its content to the response supplied. If there is any reason we need to encode URLs for this response (i.e. there is a base directory, url rewriting is on or exit tracking is on), we will parse the HTML file and encode any URLs inside using the request.encodeURL method. If there is no reason to be encoding URLs, the output is just written to the browser as fast as possible. If the pCacheData parameter is passed with true, caching is used for both the input file data and an offset table is generated which represents this input file. This offset table is used then to locate URLs in the parsed file.

If URLs are encoded, and the response has not already been committed, the dynamic headers are set to indicate that this page should not be cached. If you are calling this on a response whose headers have already been commited, you must be sure to call ServletUtil.setDynamicContentHeaders yourself before the response is committed so that the headers can prevent proxy servers from caching this response.

If the response has not been committed and the pSetContentType parameter is true, the content type is also set to: "text/html; charset=the encoding you supply. You should only set this to true, if no output has been written to the response yet.

Parameters:
pRequest - the request
pResponse - the response
pFilename - the filename of the file to send. This may be used as a key to a hashtable, so it is good to ensure that some consistent form of the pathname is used.
pSrcEncoding - the name of the encoding of the file to be written. If null it passed, the default encoding in the response is used (generally ISO-8859-1).
pCacheData - if true, the parsing of the HTML file is cached using an offset table to make subsequent requests which need to encode URLs in the same HTML file faster.
Throws:
java.io.IOException - if either the response output has been closed (i.e. the browser's stop button was pressed), or if the input file could not be read. To differentiate between these two cases, you will have to try and open the file yourself after catching the IOException.

encodeHTMLFile

public static void encodeHTMLFile(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse,
                                  java.lang.String pFilename,
                                  java.lang.String pSrcEncoding,
                                  boolean pCacheData)
                           throws java.io.IOException
Takes the file name specified, parses it and encodes all URLs it found using the request.encodeURL method. The results are send to the response object given. Use writeHTMLFile to avoid parsing the HTML file in the event that encoding of URLs is not needed. This method will always call request.encodeURL for URLs found in the HTML file specified. If you want more efficient automatic operation, use the writeHTMLFile method. Use this method if you want to always encode the URLs, and/or want to set the response headers differently from what was done in writeHTMLFile. Make sure to set the response's content type before calling this method.

Parameters:
pRequest - the request
pResponse - the response
pFilename - the filename of the file to send. This may be used as a key to a hashtable, so it is good to ensure that some consistent form of the pathname is used.
pSrcEncoding - the name of the encoding of the file to be written. If null it passed, the default encoding in the response is used (generally ISO-8859-1).
pCacheData - if true, the parsing of the HTML file is cached using an offset table to make subsequent requests which need to encode URLs in the same HTML file faster.
Throws:
java.io.IOException - if either the response output has been closed (i.e. the browser's stop button was pressed), or if the input file could not be read. To differentiate between these two cases, you will have to try and open the file yourself after catching the IOException.

writeFile

public static void writeFile(DynamoHttpServletRequest pRequest,
                             DynamoHttpServletResponse pResponse,
                             java.lang.String pFilename,
                             java.lang.String pSrcEncoding,
                             boolean pCacheData)
                      throws java.io.IOException
This method will write a file to the response supplied. It does not do any encoding of URLs in the supplied content. If an encoding is supplied, it will parse the file as characters and write them through the PrintWriter. If null is passed for the encoding parameter, the file is assumed to be in the encoding of the current response, if there is one. Make sure you call response.setContentType before calling this method.

Parameters:
pRequest - the request
pResponse - the response
pFilename - the filename of the file to send. This may be used as a key to a hashtable, so it is good to ensure that some consistent form of the pathname is used.
pSrcEncoding - the name of the encoding of the file to be written. If null it passed, the default encoding in the response is used (generally ISO-8859-1).
pCacheData - if true, the parsing of the HTML file is cached using an offset table to make subsequent requests which need to encode URLs in the same HTML file faster.
Throws:
java.io.IOException - if either the response output has been closed (i.e. the browser's stop button was pressed), or if the input file could not be read. To differentiate between these two cases, you will have to try and open the file yourself after catching the IOException.