org.apache.jasper.runtime
类 JspContextWrapper

java.lang.Object
  继承者 javax.servlet.jsp.JspContext
      继承者 javax.servlet.jsp.PageContext
          继承者 org.apache.jasper.runtime.JspContextWrapper

public class JspContextWrapper
extends PageContext

Implementation of a JSP Context Wrapper. The JSP Context Wrapper is a JspContext created and maintained by a tag handler implementation. It wraps the Invoking JSP Context, that is, the JspContext instance passed to the tag handler by the invoking page via setJspContext().

作者:
Kin-man Chung, Jan Luehe

字段摘要
 
从类 javax.servlet.jsp.PageContext 继承的字段
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
 
构造方法摘要
JspContextWrapper(JspContext jspContext, ArrayList<String> nestedVars, ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String,String> aliases)
           
 
方法摘要
 Object findAttribute(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(String relativeUrlPath)
           This method is used to re-direct, or "forward" the current ServletRequest and ServletResponse to another active component in the application.
 Object getAttribute(String name)
          Returns the object associated with the name in the page scope or null if not found.
 Object getAttribute(String name, int scope)
          Return the object associated with the name in the specified scope or null if not found.
 Enumeration<String> getAttributeNamesInScope(int scope)
          Enumerate all the attributes in a given scope.
 int getAttributesScope(String name)
          Get the scope where a given attribute is defined.
 ELContext getELContext()
          Returns the ELContext associated with this JspContext.
 Exception getException()
          The current value of the exception object (an Exception).
 ExpressionEvaluator getExpressionEvaluator()
          Provides programmatic access to the ExpressionEvaluator.
 JspWriter getOut()
          The current value of the out object (a JspWriter).
 Object getPage()
          The current value of the page object (In a Servlet environment, this is an instance of javax.servlet.Servlet).
 ServletRequest getRequest()
          The current value of the request object (a ServletRequest).
 ServletResponse getResponse()
          The current value of the response object (a ServletResponse).
static PageContext getRootPageContext(PageContext pc)
           
 ServletConfig getServletConfig()
          The ServletConfig instance.
 ServletContext getServletContext()
          The ServletContext instance.
 HttpSession getSession()
          The current value of the session object (an HttpSession).
 VariableResolver getVariableResolver()
          Returns an instance of a VariableResolver that provides access to the implicit objects specified in the JSP specification using this JspContext as the context object.
 void handlePageException(Exception ex)
           This method is intended to process an unhandled 'page' level exception by forwarding the exception to the specified error page for this JSP.
 void handlePageException(Throwable t)
           This method is intended to process an unhandled 'page' level exception by forwarding the exception to the specified error page for this JSP.
 void include(String relativeUrlPath)
           Causes the resource specified to be processed as part of the current ServletRequest and ServletResponse being processed by the calling Thread.
 void include(String relativeUrlPath, boolean flush)
           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, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
           The initialize method 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 within 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 JspContext.
 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.
 JspWriter pushBody(Writer writer)
          Return a new JspWriter object that sends output to the provided Writer.
 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(String name)
          Remove the object reference associated with the given name from all scopes.
 void removeAttribute(String name, int scope)
          Remove the object reference associated with the specified name in the given scope.
 void setAttribute(String name, Object value)
          Register the name and value specified with page scope semantics.
 void setAttribute(String name, Object value, int scope)
          Register the name and value specified with appropriate scope semantics.
 void syncBeforeInvoke()
          Synchronize variables before fragment invokation
 void syncBeginTagFile()
          Synchronize variables at begin of tag file
 void syncEndTagFile()
          Synchronize variables at end of tag file
 
从类 javax.servlet.jsp.PageContext 继承的方法
getErrorData
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

JspContextWrapper

public JspContextWrapper(JspContext jspContext,
                         ArrayList<String> nestedVars,
                         ArrayList<String> atBeginVars,
                         ArrayList<String> atEndVars,
                         Map<String,String> aliases)
方法详细信息

initialize

public void initialize(Servlet servlet,
                       ServletRequest request,
                       ServletResponse response,
                       String errorPageURL,
                       boolean needsSession,
                       int bufferSize,
                       boolean autoFlush)
                throws IOException,
                       IllegalStateException,
                       IllegalArgumentException
从类 PageContext 复制的描述

The initialize method 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 within 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.

This method should not be used by page or tag library authors.

指定者:
PageContext 中的 initialize
参数:
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
抛出:
IOException - during creation of JspWriter
IllegalStateException - if out not correctly initialized
IllegalArgumentException - If one of the given parameters is invalid

getAttribute

public Object getAttribute(String name)
从类 JspContext 复制的描述
Returns the object associated with the name in the page scope or null if not found.

指定者:
JspContext 中的 getAttribute
参数:
name - the name of the attribute to get
返回:
the object associated with the name in the page scope or null if not found.

getAttribute

public Object getAttribute(String name,
                           int scope)
从类 JspContext 复制的描述
Return the object associated with the name in the specified scope or null if not found.

指定者:
JspContext 中的 getAttribute
参数:
name - the name of the attribute to set
scope - the scope with which to associate the name/object
返回:
the object associated with the name in the specified scope or null if not found.

setAttribute

public void setAttribute(String name,
                         Object value)
从类 JspContext 复制的描述
Register the name and value specified with page scope semantics. If the value passed in is null, this has the same effect as calling removeAttribute( name, PageContext.PAGE_SCOPE ).

指定者:
JspContext 中的 setAttribute
参数:
name - the name of the attribute to set
value - the value to associate with the name, or null if the attribute is to be removed from the page scope.

setAttribute

public void setAttribute(String name,
                         Object value,
                         int scope)
从类 JspContext 复制的描述
Register the name and value specified with appropriate scope semantics. If the value passed in is null, this has the same effect as calling removeAttribute( name, scope ).

指定者:
JspContext 中的 setAttribute
参数:
name - the name of the attribute to set
value - the object to associate with the name, or null if the attribute is to be removed from the specified scope.
scope - the scope with which to associate the name/object

findAttribute

public Object findAttribute(String name)
从类 JspContext 复制的描述
Searches for the named attribute in page, request, session (if valid), and application scope(s) in order and returns the value associated or null.

指定者:
JspContext 中的 findAttribute
参数:
name - the name of the attribute to search for
返回:
the value associated or null

removeAttribute

public void removeAttribute(String name)
从类 JspContext 复制的描述
Remove the object reference associated with the given name from all scopes. Does nothing if there is no such object.

指定者:
JspContext 中的 removeAttribute
参数:
name - The name of the object to remove.

removeAttribute

public void removeAttribute(String name,
                            int scope)
从类 JspContext 复制的描述
Remove the object reference associated with the specified name in the given scope. Does nothing if there is no such object.

指定者:
JspContext 中的 removeAttribute
参数:
name - The name of the object to remove.
scope - The scope where to look.

getAttributesScope

public int getAttributesScope(String name)
从类 JspContext 复制的描述
Get the scope where a given attribute is defined.

指定者:
JspContext 中的 getAttributesScope
参数:
name - the name of the attribute to return the scope for
返回:
the scope of the object associated with the name specified or 0

getAttributeNamesInScope

public Enumeration<String> getAttributeNamesInScope(int scope)
从类 JspContext 复制的描述
Enumerate all the attributes in a given scope.

指定者:
JspContext 中的 getAttributeNamesInScope
参数:
scope - the scope to enumerate all the attributes for
返回:
an enumeration of names (java.lang.String) of all the attributes the specified scope

release

public void release()
从类 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.

This method should not be used by page or tag library authors.

指定者:
PageContext 中的 release

getOut

public JspWriter getOut()
从类 JspContext 复制的描述
The current value of the out object (a JspWriter).

指定者:
JspContext 中的 getOut
返回:
the current JspWriter stream being used for client response

getSession

public HttpSession getSession()
从类 PageContext 复制的描述
The current value of the session object (an HttpSession).

指定者:
PageContext 中的 getSession
返回:
the HttpSession for this PageContext or null

getPage

public Object getPage()
从类 PageContext 复制的描述
The current value of the page object (In a Servlet environment, this is an instance of javax.servlet.Servlet).

指定者:
PageContext 中的 getPage
返回:
the Page implementation class instance associated with this PageContext

getRequest

public ServletRequest getRequest()
从类 PageContext 复制的描述
The current value of the request object (a ServletRequest).

指定者:
PageContext 中的 getRequest
返回:
The ServletRequest for this PageContext

getResponse

public ServletResponse getResponse()
从类 PageContext 复制的描述
The current value of the response object (a ServletResponse).

指定者:
PageContext 中的 getResponse
返回:
the ServletResponse for this PageContext

getException

public Exception getException()
从类 PageContext 复制的描述
The current value of the exception object (an Exception).

指定者:
PageContext 中的 getException
返回:
any exception passed to this as an errorpage

getServletConfig

public ServletConfig getServletConfig()
从类 PageContext 复制的描述
The ServletConfig instance.

指定者:
PageContext 中的 getServletConfig
返回:
the ServletConfig for this PageContext

getServletContext

public ServletContext getServletContext()
从类 PageContext 复制的描述
The ServletContext instance.

指定者:
PageContext 中的 getServletContext
返回:
the ServletContext for this PageContext

getRootPageContext

public static PageContext getRootPageContext(PageContext pc)

getELContext

public ELContext getELContext()
从类 JspContext 复制的描述
Returns the ELContext associated with this JspContext.

The ELContext is created lazily and is reused if it already exists. There is a new ELContext for each JspContext.

The ELContext must contain the ELResolver described in the JSP specification (and in the javadocs for JspApplicationContext.addELResolver(javax.el.ELResolver)).

指定者:
JspContext 中的 getELContext
返回:
The ELContext associated with this JspContext.

forward

public void forward(String relativeUrlPath)
             throws ServletException,
                    IOException
从类 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.

指定者:
PageContext 中的 forward
参数:
relativeUrlPath - specifies the relative URL path to the target resource as described above
抛出:
ServletException - if the page that was forwarded to throws a ServletException
IOException - if an I/O error occurred while forwarding

include

public void include(String relativeUrlPath)
             throws ServletException,
                    IOException
从类 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.

指定者:
PageContext 中的 include
参数:
relativeUrlPath - specifies the relative URL path to the target resource to be included
抛出:
ServletException - if the page that was forwarded to throws a ServletException
IOException - if an I/O error occurred while forwarding

include

public void include(String relativeUrlPath,
                    boolean flush)
             throws ServletException,
                    IOException
从类 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 current JspWriter returned by a call to getOut().

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

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.

指定者:
PageContext 中的 include
参数:
relativeUrlPath - specifies the relative URL path to the target resource to be included
flush - True if the JspWriter is to be flushed before the include, or false if not.
抛出:
ServletException - if the page that was forwarded to throws a ServletException
IOException - if an I/O error occurred while forwarding

getVariableResolver

public VariableResolver getVariableResolver()
从类 JspContext 复制的描述
Returns an instance of a VariableResolver that provides access to the implicit objects specified in the JSP specification using this JspContext as the context object.

指定者:
JspContext 中的 getVariableResolver
返回:
A valid instance of a VariableResolver.

pushBody

public BodyContent pushBody()
从类 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.

覆盖:
PageContext 中的 pushBody
返回:
the new BodyContent

pushBody

public JspWriter pushBody(Writer writer)
从类 JspContext 复制的描述
Return a new JspWriter object that sends output to the provided Writer. Saves the current "out" JspWriter, and updates the value of the "out" attribute in the page scope attribute namespace of the JspContext.

The returned JspWriter must implement all methods and behave as though it were unbuffered. More specifically:

覆盖:
JspContext 中的 pushBody
参数:
writer - The Writer for the returned JspWriter to send output to.
返回:
a new JspWriter that writes to the given Writer.

popBody

public JspWriter popBody()
从类 JspContext 复制的描述
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 JspContext.

覆盖:
JspContext 中的 popBody
返回:
the saved JspWriter.

getExpressionEvaluator

public ExpressionEvaluator getExpressionEvaluator()
从类 JspContext 复制的描述
Provides programmatic access to the ExpressionEvaluator. The JSP Container must return a valid instance of an ExpressionEvaluator that can parse EL expressions.

指定者:
JspContext 中的 getExpressionEvaluator
返回:
A valid instance of an ExpressionEvaluator.

handlePageException

public void handlePageException(Exception ex)
                         throws IOException,
                                ServletException
从类 PageContext 复制的描述

This method is intended to process an unhandled 'page' level exception by forwarding the exception to the specified error page for this JSP. If forwarding is not possible (for example because the response has already been committed), an implementation dependent mechanism should be used to invoke the error page (e.g. "including" the error page instead).

If no error page is defined in the page, the exception should be rethrown so that the standard servlet error handling takes over.

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.

This method is kept for backwards compatiblity reasons. Newly generated code should use PageContext.handlePageException(Throwable).

指定者:
PageContext 中的 handlePageException
参数:
ex - the exception to be handled
抛出:
IOException - if an I/O error occurred while invoking the error page
ServletException - if an error occurs while invoking the error page
另请参见:
PageContext.handlePageException(Throwable)

handlePageException

public void handlePageException(Throwable t)
                         throws IOException,
                                ServletException
从类 PageContext 复制的描述

This method is intended to process an unhandled 'page' level exception by forwarding the exception to the specified error page for this JSP. If forwarding is not possible (for example because the response has already been committed), an implementation dependent mechanism should be used to invoke the error page (e.g. "including" the error page instead).

If no error page is defined in the page, the exception should be rethrown so that the standard servlet error handling takes over.

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.

指定者:
PageContext 中的 handlePageException
参数:
t - the throwable to be handled
抛出:
IOException - if an I/O error occurred while invoking the error page
ServletException - if an error occurs while invoking the error page
另请参见:
PageContext.handlePageException(Exception)

syncBeginTagFile

public void syncBeginTagFile()
Synchronize variables at begin of tag file


syncBeforeInvoke

public void syncBeforeInvoke()
Synchronize variables before fragment invokation


syncEndTagFile

public void syncEndTagFile()
Synchronize variables at end of tag file



Copyright © 2013. All Rights Reserved.