org.apache.jasper.runtime
Class PageContextImpl

java.lang.Object
  |
  +--javax.servlet.jsp.PageContext
        |
        +--org.apache.jasper.runtime.PageContextImpl

public class PageContextImpl
extends PageContext

Implementation of the PageContext class from the JSP spec.

Author:
Anil K. Vijendran, Larry Cable, Hans Bergsten

Fields inherited from class javax.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
 
Method Summary
 java.lang.Object findAttribute(java.lang.String name)
           Searches for the named attribute in page, request, session (if valid), and application scope(s) in order and returns the value associated or null.
 void forward(java.lang.String relativeUrlPath)
           This method is used to re-direct, or "forward" the current ServletRequest and ServletResponse to another active component in the application.
 java.lang.Object getAttribute(java.lang.String name)
          return the object associated with the name in the page scope or null
 java.lang.Object getAttribute(java.lang.String name, int scope)
          return the object associated with the name in the specifed scope or null
 java.util.Enumeration getAttributeNamesInScope(int scope)
           
 int getAttributesScope(java.lang.String name)
           
 java.lang.Exception getException()
           
 JspWriter getOut()
           
 java.lang.Object getPage()
           
 ServletRequest getRequest()
           
 ServletResponse getResponse()
           
 Servlet getServlet()
           
 ServletConfig getServletConfig()
           
 ServletContext getServletContext()
           
 HttpSession getSession()
           
 void handlePageException(java.lang.Exception e)
           This method is intended to process an unhandled "page" level exception by redirecting the exception to either the specified error page for this JSP, or if none was specified, to perform some implementation dependent action.
 void include(java.lang.String relativeUrlPath)
           Causes the resource specified to be processed as part of the current ServletRequest and ServletResponse being processed by the calling Thread.
 void initialize(Servlet servlet, ServletRequest request, ServletResponse response, java.lang.String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
           The initialize emthod is called to initialize an uninitialized PageContext so that it may be used by a JSP Implementation class to service an incoming request and response wihtin it's _jspService() method.
 JspWriter popBody()
          Return the previous JspWriter "out" saved by the matching pushBody(), and update the value of the "out" attribute in the page scope attribute namespace of the PageConxtext
 BodyContent pushBody()
          Return a new BodyContent object, save the current "out" JspWriter, and update the value of the "out" attribute in the page scope attribute namespace of the PageContext
 void release()
           This method shall "reset" the internal state of a PageContext, releasing all internal references, and preparing the PageContext for potential reuse by a later invocation of initialize().
 void removeAttribute(java.lang.String name)
          remove the object reference associated with the specified name
 void removeAttribute(java.lang.String name, int scope)
          remove the object reference associated with the specified name
 void setAttribute(java.lang.String name, java.lang.Object attribute)
          register the name and object specified with page scope semantics
 void setAttribute(java.lang.String name, java.lang.Object o, int scope)
          register the name and object specified with appropriate scope semantics
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public void initialize(Servlet servlet,
                       ServletRequest request,
                       ServletResponse response,
                       java.lang.String errorPageURL,
                       boolean needsSession,
                       int bufferSize,
                       boolean autoFlush)
                throws java.io.IOException,
                       java.lang.IllegalStateException,
                       java.lang.IllegalArgumentException
Description copied from class: PageContext

The initialize emthod is called to initialize an uninitialized PageContext so that it may be used by a JSP Implementation class to service an incoming request and response wihtin it's _jspService() method.

This method is typically called from JspFactory.getPageContext() in order to initialize state.

This method is required to create an initial JspWriter, and associate the "out" name in page scope with this newly created object.

Overrides:
initialize in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
servlet - The Servlet that is associated with this PageContext
request - The currently pending request for this Servlet
response - The currently pending response for this Servlet
errorPageURL - The value of the errorpage attribute from the page directive or null
needsSession - The value of the session attribute from the page directive
bufferSize - The value of the buffer attribute from the page directive
autoFlush - The value of the autoflush attribute from the page directive
Throws:
java.io.IOException - during creation of JspWriter
java.lang.IllegalStateException - if out not correctly initialized

release

public void release()
Description copied from class: PageContext

This method shall "reset" the internal state of a PageContext, releasing all internal references, and preparing the PageContext for potential reuse by a later invocation of initialize(). This method is typically called from JspFactory.releasePageContext().

subclasses shall envelope this method

Overrides:
release in class PageContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from class: PageContext

return the object associated with the name in the page scope or null

Overrides:
getAttribute in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
name - the name of the attribute to get
Throws:
java.lang.NullPointerException - if the name is null
java.lang.IllegalArgumentException - if the scope is invalid

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Description copied from class: PageContext

return the object associated with the name in the specifed scope or null

Overrides:
getAttribute in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
name - the name of the attribute to set
scope - the scope with which to associate the name/object
Throws:
java.lang.NullPointerException - if the name is null
java.lang.IllegalArgumentException - if the scope is invalid

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attribute)
Description copied from class: PageContext
register the name and object specified with page scope semantics
Overrides:
setAttribute in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Throws:
java.lang.NullPointerException - if the name or object is null

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object o,
                         int scope)
Description copied from class: PageContext
register the name and object specified with appropriate scope semantics
Overrides:
setAttribute in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
name - the name of the attribute to set
o - the object to associate with the name
scope - the scope with which to associate the name/object
Throws:
java.lang.NullPointerException - if the name or object is null
java.lang.IllegalArgumentException - if the scope is invalid

removeAttribute

public void removeAttribute(java.lang.String name,
                            int scope)
Description copied from class: PageContext
remove the object reference associated with the specified name
Overrides:
removeAttribute in class PageContext

getAttributesScope

public int getAttributesScope(java.lang.String name)
Overrides:
getAttributesScope in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the scope of the object associated with the name specified or 0

findAttribute

public java.lang.Object findAttribute(java.lang.String name)
Description copied from class: PageContext

Searches for the named attribute in page, request, session (if valid), and application scope(s) in order and returns the value associated or null.

Overrides:
findAttribute in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the value associated or null

getAttributeNamesInScope

public java.util.Enumeration getAttributeNamesInScope(int scope)
Overrides:
getAttributeNamesInScope in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
an enumeration of names (java.lang.String) of all the attributes the specified scope

removeAttribute

public void removeAttribute(java.lang.String name)
Description copied from class: PageContext
remove the object reference associated with the specified name
Overrides:
removeAttribute in class PageContext

getOut

public JspWriter getOut()
Overrides:
getOut in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the current JspWriter stream being used for client response

getSession

public HttpSession getSession()
Overrides:
getSession in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the HttpSession for this PageContext or null

getServlet

public Servlet getServlet()

getServletConfig

public ServletConfig getServletConfig()
Overrides:
getServletConfig in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the ServletConfig for this PageContext

getServletContext

public ServletContext getServletContext()
Overrides:
getServletContext in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the ServletContext for this PageContext

getRequest

public ServletRequest getRequest()
Overrides:
getRequest in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
The ServletRequest for this PageContext

getResponse

public ServletResponse getResponse()
Overrides:
getResponse in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the ServletResponse for this PageContext

getException

public java.lang.Exception getException()
Overrides:
getException in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
any exception passed to this as an errorpage

getPage

public java.lang.Object getPage()
Overrides:
getPage in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the Page implementation class instance (Servlet) associated with this PageContext

include

public void include(java.lang.String relativeUrlPath)
             throws ServletException,
                    java.io.IOException
Description copied from class: PageContext

Causes the resource specified to be processed as part of the current ServletRequest and ServletResponse being processed by the calling Thread. The output of the target resources processing of the request is written directly to the ServletResponse output stream.

The current JspWriter "out" for this JSP is flushed as a side-effect of this call, prior to processing the include.

If the relativeUrlPath begins with a "/" then the URL specified is calculated relative to the DOCROOT of the ServletContext for this JSP. If the path does not begin with a "/" then the URL specified is calculated relative to the URL of the request that was mapped to the calling JSP.

It is only valid to call this method from a Thread executing within a _jspService(...) method of a JSP.

Overrides:
include in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
relativeUrlPath - specifies the relative URL path to the target resource to be included
Throws:
ServletException -  
java.io.IOException -  
java.lang.IllegalArgumentException - if the target resource URL is unresolvable
java.lang.SecurityException - if target resource cannot be accessed by caller

forward

public void forward(java.lang.String relativeUrlPath)
             throws ServletException,
                    java.io.IOException
Description copied from class: PageContext

This method is used to re-direct, or "forward" the current ServletRequest and ServletResponse to another active component in the application.

If the relativeUrlPath begins with a "/" then the URL specified is calculated relative to the DOCROOT of the ServletContext for this JSP. If the path does not begin with a "/" then the URL specified is calculated relative to the URL of the request that was mapped to the calling JSP.

It is only valid to call this method from a Thread executing within a _jspService(...) method of a JSP.

Once this method has been called successfully, it is illegal for the calling Thread to attempt to modify the ServletResponse object. Any such attempt to do so, shall result in undefined behavior. Typically, callers immediately return from _jspService(...) after calling this method.

Overrides:
forward in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
relativeUrlPath - specifies the relative URL path to the target resource as described above
Throws:
ServletException -  
java.io.IOException -  
java.lang.IllegalArgumentException - if target resource URL is unresolvable
java.lang.IllegalStateException - if ServletResponse is not in a state where a forward can be performed
java.lang.SecurityException - if target resource cannot be accessed by caller

pushBody

public BodyContent pushBody()
Description copied from class: PageContext
Return a new BodyContent object, save the current "out" JspWriter, and update the value of the "out" attribute in the page scope attribute namespace of the PageContext
Overrides:
pushBody in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the new BodyContent

popBody

public JspWriter popBody()
Description copied from class: PageContext
Return the previous JspWriter "out" saved by the matching pushBody(), and update the value of the "out" attribute in the page scope attribute namespace of the PageConxtext
Overrides:
popBody in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Returns:
the saved JspWriter.

handlePageException

public void handlePageException(java.lang.Exception e)
                         throws java.io.IOException,
                                ServletException
Description copied from class: PageContext

This method is intended to process an unhandled "page" level exception by redirecting the exception to either the specified error page for this JSP, or if none was specified, to perform some implementation dependent action.

A JSP implementation class shall typically clean up any local state prior to invoking this and will return immediately thereafter. It is illegal to generate any output to the client, or to modify any ServletResponse state after invoking this call.

Overrides:
handlePageException in class PageContext
Following copied from class: javax.servlet.jsp.PageContext
Parameters:
e - the exception to be handled
Throws:
ServletException -  
java.io.IOException -  
java.lang.NullPointerException - if the exception is null
java.lang.SecurityException - if target resource cannot be accessed by caller


Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.