org.directwebremoting.servlet
Class FileHandler

java.lang.Object
  extended by org.directwebremoting.servlet.FileHandler
All Implemented Interfaces:
Handler, InitializingBean
Direct Known Subclasses:
AuthHandler, EngineHandler, UtilHandler, WebworkUtilHandler

public class FileHandler
extends java.lang.Object
implements Handler, InitializingBean

Basically a file servlet component that does some very limitted EL type processing on the file. See the source for the cheat.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
protected  int compressionLevel
          How much do we compression javascript by?
protected  IdGenerator generator
          The method by which we get new page ids
protected  boolean ignoreLastModified
          Do we ignore all the Last-Modified/ETags blathering?
protected  int maxWaitAfterWrite
          Sometimes with proxies, you need to close the stream all the time to make the flush work.
protected  int pageIdLength
          The page id length
protected static java.lang.String PARAM_DEFAULT_PATH
          What is the replacement field we use to tell engine.js what we are using for script tag hack protection
protected static java.lang.String PARAM_SCRIPT_ALLOWGET
          Does engine.js do GETs for Safari
protected static java.lang.String PARAM_SCRIPT_COOKIENAME
          Under what cookie name is the session id stored?
protected static java.lang.String PARAM_SCRIPT_POLLXHR
          Doe we force polling with XHR on IE to prevent clicking
protected static java.lang.String PARAM_SCRIPT_SESSIONID
          The page id parameter that goes in engine.js
protected static java.lang.String PARAM_SCRIPT_TAG_PROTECTION
          What is the replacement field we use to tell engine.js what we are using for script tag hack protection
protected  java.util.Map scriptCache
          We cache the script output for speed
protected  boolean scriptCompressed
          Do we retain comments and unneeded spaces in Javascript code?
protected  java.lang.String sessionCookieName
          The session cookie name
 
Constructor Summary
FileHandler()
          Create a new FileHandler
FileHandler(java.lang.String filePath, java.lang.String mimeType, boolean dynamic)
          Create a new FileHandler
 
Method Summary
 void afterContainerSetup(Container container)
          This method allows the bean instance to perform initialization only possible when all bean properties have been set
 void handle(HttpServletRequest request, HttpServletResponse response)
          Handle a URL request that has been mapped to this Handler
 void setAllowGetForSafariButMakeForgeryEasier(boolean allowGetForSafariButMakeForgeryEasier)
           
 void setCompressionLevel(int compressionLevel)
           
 void setDynamic(boolean dynamic)
          Are we expected to do the minor EL type processing?
 void setFilePath(java.lang.String filePath)
           
 void setIgnoreLastModified(boolean ignoreLastModified)
           
 void setMaxWaitAfterWrite(int maxWaitAfterWrite)
          Sometimes with proxies, you need to close the stream all the time to make the flush work.
 void setMimeType(java.lang.String mimeType)
          The mime type to send the output under
 void setOverridePath(java.lang.String overridePath)
          If we need to override the default path
 void setScriptCompressed(boolean scriptCompressed)
          To what level do we compress scripts?
 void setScriptTagProtection(java.lang.String scriptTagProtection)
          What is the string we use for script tag hack protection
 void setSessionCookieName(java.lang.String sessionCookieName)
          Alter the session cookie name from the default JSESSIONID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ignoreLastModified

protected boolean ignoreLastModified
Do we ignore all the Last-Modified/ETags blathering?


maxWaitAfterWrite

protected int maxWaitAfterWrite
Sometimes with proxies, you need to close the stream all the time to make the flush work. A value of -1 indicated that we do not do early closing after writes. See also: org.directwebremoting.dwrp.PollHandler.maxWaitAfterWrite


sessionCookieName

protected java.lang.String sessionCookieName
The session cookie name


compressionLevel

protected int compressionLevel
How much do we compression javascript by?


scriptCompressed

protected boolean scriptCompressed
Do we retain comments and unneeded spaces in Javascript code?


generator

protected IdGenerator generator
The method by which we get new page ids


pageIdLength

protected int pageIdLength
The page id length


scriptCache

protected final java.util.Map scriptCache
We cache the script output for speed


PARAM_SCRIPT_ALLOWGET

protected static final java.lang.String PARAM_SCRIPT_ALLOWGET
Does engine.js do GETs for Safari

See Also:
Constant Field Values

PARAM_SCRIPT_POLLXHR

protected static final java.lang.String PARAM_SCRIPT_POLLXHR
Doe we force polling with XHR on IE to prevent clicking

See Also:
Constant Field Values

PARAM_SCRIPT_SESSIONID

protected static final java.lang.String PARAM_SCRIPT_SESSIONID
The page id parameter that goes in engine.js

See Also:
Constant Field Values

PARAM_SCRIPT_COOKIENAME

protected static final java.lang.String PARAM_SCRIPT_COOKIENAME
Under what cookie name is the session id stored?

See Also:
Constant Field Values

PARAM_SCRIPT_TAG_PROTECTION

protected static final java.lang.String PARAM_SCRIPT_TAG_PROTECTION
What is the replacement field we use to tell engine.js what we are using for script tag hack protection

See Also:
Constant Field Values

PARAM_DEFAULT_PATH

protected static final java.lang.String PARAM_DEFAULT_PATH
What is the replacement field we use to tell engine.js what we are using for script tag hack protection

See Also:
Constant Field Values
Constructor Detail

FileHandler

public FileHandler(java.lang.String filePath,
                   java.lang.String mimeType,
                   boolean dynamic)
Create a new FileHandler

Parameters:
filePath - The filePath to search for, process and output
mimeType - The mime type to use for this output file
dynamic - Should the script be recalculated each time?

FileHandler

public FileHandler()
Create a new FileHandler

Method Detail

afterContainerSetup

public void afterContainerSetup(Container container)
Description copied from interface: InitializingBean

This method allows the bean instance to perform initialization only possible when all bean properties have been set

Specified by:
afterContainerSetup in interface InitializingBean
Parameters:
container - The container that is doing the initialization

handle

public void handle(HttpServletRequest request,
                   HttpServletResponse response)
            throws java.io.IOException
Description copied from interface: Handler
Handle a URL request that has been mapped to this Handler

Specified by:
handle in interface Handler
Parameters:
request - The HTTP request data
response - Where we write the HTTP response data
Throws:
java.io.IOException - If the write process fails

setAllowGetForSafariButMakeForgeryEasier

public void setAllowGetForSafariButMakeForgeryEasier(boolean allowGetForSafariButMakeForgeryEasier)
Parameters:
allowGetForSafariButMakeForgeryEasier - Do we reduce security to help Safari

setIgnoreLastModified

public void setIgnoreLastModified(boolean ignoreLastModified)
Parameters:
ignoreLastModified - The ignoreLastModified to set.

setSessionCookieName

public void setSessionCookieName(java.lang.String sessionCookieName)
Alter the session cookie name from the default JSESSIONID.

Parameters:
sessionCookieName - the sessionCookieName to set

setScriptCompressed

public void setScriptCompressed(boolean scriptCompressed)
To what level do we compress scripts?

Parameters:
scriptCompressed - The scriptCompressed to set.

setCompressionLevel

public void setCompressionLevel(int compressionLevel)
Parameters:
compressionLevel - The compressionLevel to set.

setFilePath

public void setFilePath(java.lang.String filePath)
Parameters:
filePath - the filePath to set

setDynamic

public void setDynamic(boolean dynamic)
Are we expected to do the minor EL type processing?

Parameters:
dynamic - the dynamic to set

setMimeType

public void setMimeType(java.lang.String mimeType)
The mime type to send the output under

Parameters:
mimeType - the mimeType to set

setScriptTagProtection

public void setScriptTagProtection(java.lang.String scriptTagProtection)
What is the string we use for script tag hack protection

Parameters:
scriptTagProtection - the scriptTagProtection to set

setOverridePath

public void setOverridePath(java.lang.String overridePath)
If we need to override the default path

Parameters:
overridePath - The new override path

setMaxWaitAfterWrite

public void setMaxWaitAfterWrite(int maxWaitAfterWrite)
Sometimes with proxies, you need to close the stream all the time to make the flush work. A value of -1 indicated that we do not do early closing after writes.

Parameters:
maxWaitAfterWrite - the maxWaitAfterWrite to set