com.caucho.jsp
Class Page

java.lang.Object
  |
  +--com.caucho.jsp.Page
All Implemented Interfaces:
CauchoPage, Servlet, ServletConfig
Direct Known Subclasses:
JavaPage

public abstract class Page
extends java.lang.Object
implements Servlet, ServletConfig, CauchoPage

Represents a compiled JSP page.


Field Summary
protected  boolean alwaysModified
           
protected  java.lang.String contentType
           
protected static WriteStream dbg
           
protected  boolean neverModified
           
 
Constructor Summary
Page()
           
 
Method Summary
protected  void _caucho_addCacheDepend(Path path, long lastModified, long length)
          Adds a single cache dependency.
protected  void _caucho_addDepend(Path path)
          Adds a dependency to the page.
protected  void _caucho_addDepend(Path path, long lastModified, long length)
          Adds a JSP source dependency.
 com.caucho.java.LineMap _caucho_getLineMap()
           
 void _caucho_init(HttpServletRequest req, HttpServletResponse res)
          Initialize the response headers.
 boolean _caucho_isModified()
          Returns true if the underlying source has been modified.
 long _caucho_lastModified()
          The default Last-Modified time is just the most recently modified file.
protected  void _caucho_setAlwaysModified()
          When called treats the JSP page as always modified, i.e.
protected  void _caucho_setCacheable()
          Marks the page as cacheable.
protected  void _caucho_setContentType(java.lang.String contentType, java.lang.String encoding)
           
protected  void _caucho_setModified()
          When called treats the JSP page as always modified, i.e.
protected  void _caucho_setNeverModified(boolean modified)
          Set if the page is never modified.
static long calculateLastModified(java.util.ArrayList depends, java.util.ArrayList cacheDepends)
          Calculate the last modified time for all the dependencies.
 boolean cauchoIsModified()
          Returns true if the underlying source has been modified.
 void destroy()
          Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
 java.lang.String getInitParameter(java.lang.String name)
          Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
 java.util.Enumeration getInitParameterNames()
          Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
 long getLastModified(HttpServletRequest request)
          Returns the Last-Modified time for use in caching.
 ServletConfig getServletConfig()
          Returns this servlet's configuration.
 ServletContext getServletContext()
          Returns a reference to the ServletContext in which the caller is executing.
 java.lang.String getServletInfo()
          Returns information about the servlet, such as author, version, and copyright.
 java.lang.String getServletName()
          Returns the name of this servlet instance.
 void init(com.caucho.java.LineMap lineMap, Path path)
           
 void init(ServletConfig config)
          Initialize the servlet.
 boolean isDead()
           
 void log(java.lang.String msg)
           
 void log(java.lang.String msg, java.lang.Throwable cause)
           
 void subservice(CauchoRequest req, CauchoResponse res)
          The extended service method creates JavaScript global variables from a property map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.Servlet
service
 

Field Detail

dbg

protected static WriteStream dbg

contentType

protected java.lang.String contentType

alwaysModified

protected boolean alwaysModified

neverModified

protected boolean neverModified
Constructor Detail

Page

public Page()
Method Detail

init

public void init(com.caucho.java.LineMap lineMap,
                 Path path)
          throws ServletException
Specified by:
init in interface CauchoPage

_caucho_setContentType

protected void _caucho_setContentType(java.lang.String contentType,
                                      java.lang.String encoding)

_caucho_setAlwaysModified

protected void _caucho_setAlwaysModified()
When called treats the JSP page as always modified, i.e. always forcing recompilation.

_caucho_setModified

protected void _caucho_setModified()
When called treats the JSP page as always modified, i.e. always forcing recompilation.

_caucho_setNeverModified

protected void _caucho_setNeverModified(boolean modified)
Set if the page is never modified. Some users want to deploy the JSP classes without the JSP source.

_caucho_addDepend

protected void _caucho_addDepend(Path path)
Adds a dependency to the page.
Parameters:
path - the file the JSP page is dependent on.

_caucho_addDepend

protected void _caucho_addDepend(Path path,
                                 long lastModified,
                                 long length)
Adds a JSP source dependency. If the source file changes, the JSP must be recompiled.
Parameters:
path - the path to the file
lastModified - the last modified time
length - the length of the file

_caucho_setCacheable

protected void _caucho_setCacheable()
Marks the page as cacheable.

_caucho_addCacheDepend

protected void _caucho_addCacheDepend(Path path,
                                      long lastModified,
                                      long length)
Adds a single cache dependency. A cache dependency will cause the page to be rerun, but will not force a recompilation of the JSP.
Parameters:
path - the path to the file
lastModified - the last modified time
length - the length of the file

_caucho_isModified

public boolean _caucho_isModified()
Returns true if the underlying source has been modified.
Specified by:
_caucho_isModified in interface CauchoPage

cauchoIsModified

public boolean cauchoIsModified()
Returns true if the underlying source has been modified.

init

public void init(ServletConfig config)
          throws ServletException
Initialize the servlet.
Specified by:
init in interface Servlet
Following copied from interface: javax.servlet.Servlet
Parameters:
config - a ServletConfig object containing the servlet's configuration and initialization parameters
Throws:
ServletException - if an exception has occurred that interferes with the servlet's normal operation
See Also:
UnavailableException, Servlet.getServletConfig()

getServletContext

public ServletContext getServletContext()
Description copied from interface: ServletConfig
Returns a reference to the ServletContext in which the caller is executing.
Specified by:
getServletContext in interface ServletConfig
Following copied from interface: javax.servlet.ServletConfig
Returns:
a ServletContext object, used by the caller to interact with its servlet container
See Also:
ServletContext

getServletName

public java.lang.String getServletName()
Description copied from interface: ServletConfig
Returns the name of this servlet instance. The name may be provided via server administration, assigned in the web application deployment descriptor, or for an unregistered (and thus unnamed) servlet instance it will be the servlet's class name.
Specified by:
getServletName in interface ServletConfig
Following copied from interface: javax.servlet.ServletConfig
Returns:
the name of the servlet instance

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Description copied from interface: ServletConfig
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
Specified by:
getInitParameter in interface ServletConfig
Following copied from interface: javax.servlet.ServletConfig
Parameters:
name - a String specifying the name of the initialization parameter
Returns:
a String containing the value of the initialization parameter

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Description copied from interface: ServletConfig
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
Specified by:
getInitParameterNames in interface ServletConfig
Following copied from interface: javax.servlet.ServletConfig
Returns:
an Enumeration of String objects containing the names of the servlet's initialization parameters

log

public void log(java.lang.String msg)

log

public void log(java.lang.String msg,
                java.lang.Throwable cause)

getServletInfo

public java.lang.String getServletInfo()
Description copied from interface: Servlet
Returns information about the servlet, such as author, version, and copyright.

The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.).

Specified by:
getServletInfo in interface Servlet
Following copied from interface: javax.servlet.Servlet
Returns:
a String containing servlet information

getServletConfig

public ServletConfig getServletConfig()
Returns this servlet's configuration.
Specified by:
getServletConfig in interface Servlet
Following copied from interface: javax.servlet.Servlet
Returns:
the ServletConfig object that initializes this servlet
See Also:
Servlet.init(javax.servlet.ServletConfig)

_caucho_init

public void _caucho_init(HttpServletRequest req,
                         HttpServletResponse res)
Initialize the response headers.

getLastModified

public long getLastModified(HttpServletRequest request)
Returns the Last-Modified time for use in caching. If the result is <= 0, last-modified caching is disabled.
Returns:
the last modified time.

_caucho_lastModified

public long _caucho_lastModified()
The default Last-Modified time is just the most recently modified file. For JSP files, this is overwritten to always return 0.
Specified by:
_caucho_lastModified in interface CauchoPage

calculateLastModified

public static long calculateLastModified(java.util.ArrayList depends,
                                         java.util.ArrayList cacheDepends)
Calculate the last modified time for all the dependencies. The last modified time is the time of the most recently changed cache or source file.
Parameters:
depends - list of the source file dependencies
cacheDepends - list of the cache dependencies
Returns:
the last modified time in milliseconds

subservice

public void subservice(CauchoRequest req,
                       CauchoResponse res)
                throws java.io.IOException,
                       ServletException
The extended service method creates JavaScript global variables from a property map.

This method only makes sense for JavaScript templates. To pass variables to Java templates, use the setAttribute() method of the request.

Parameters:
properties - hashmap of objects to create as JavaScript globals.

isDead

public boolean isDead()

_caucho_getLineMap

public com.caucho.java.LineMap _caucho_getLineMap()
Specified by:
_caucho_getLineMap in interface CauchoPage

destroy

public void destroy()
Description copied from interface: Servlet
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet.

This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.

Specified by:
destroy in interface Servlet