📄 pagecontext.java
字号:
/**
* The current value of the request object (a ServletRequest).
*
* @return The ServletRequest for this PageContext
*/
abstract public ServletRequest getRequest();
/**
* The current value of the response object (a ServletResponse).
*
* @return the ServletResponse for this PageContext
*/
abstract public ServletResponse getResponse();
/**
* The current value of the exception object (an Exception).
*
* @return any exception passed to this as an errorpage
*/
abstract public Exception getException();
/**
* The ServletConfig instance.
*
* @return the ServletConfig for this PageContext
*/
abstract public ServletConfig getServletConfig();
/**
* The ServletContext instance.
*
* @return the ServletContext for this PageContext
*/
abstract public ServletContext getServletContext();
/**
* <p>
* This method is used to re-direct, or "forward" the current
* ServletRequest and ServletResponse to another active component in
* the application.
* </p>
* <p>
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code> ServletContext </code>
* 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.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
* <p>
* Once this method has been called successfully, it is illegal for the
* calling <code> Thread </code> to attempt to modify the <code>
* ServletResponse </code> object. Any such attempt to do so, shall result
* in undefined behavior. Typically, callers immediately return from
* <code> _jspService(...) </code> after calling this method.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the target
* resource as described above
*
* @throws IllegalStateException if <code> ServletResponse </code> is not
* in a state where a forward can be performed
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
*/
abstract public void forward(String relativeUrlPath)
throws ServletException, IOException;
/**
* <p>
* 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.
* </p>
* <p>
* The current JspWriter "out" for this JSP is flushed as a side-effect
* of this call, prior to processing the include.
* </p>
* <p>
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
* 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.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the target
* resource to be included
*
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
*/
abstract public void include(String relativeUrlPath)
throws ServletException, IOException;
/**
* <p>
* 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().
* </p>
* <p>
* 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.
* </p>
* <p>
* If the <i>relativeUrlPath</i> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
* 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.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the
* target resource to be included
* @param flush True if the JspWriter is to be flushed before the include,
* or false if not.
*
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
* @since 2.0
*/
abstract public void include(String relativeUrlPath, boolean flush)
throws ServletException, IOException;
/**
* <p>
* 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).
*
* <p>
* If no error page is defined in the page, the exception should
* be rethrown so that the standard servlet error handling
* takes over.
*
* <p>
* 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.
*
* <p>
* This method is kept for backwards compatiblity reasons. Newly
* generated code should use PageContext.handlePageException(Throwable).
*
* @param e the exception to be handled
*
* @throws ServletException if an error occurs while invoking the error page
* @throws IOException if an I/O error occurred while invoking the error
* page
* @throws NullPointerException if the exception is null
*
* @see #handlePageException(Throwable)
*/
abstract public void handlePageException(Exception e)
throws ServletException, IOException;
/**
* <p>
* 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).
*
* <p>
* If no error page is defined in the page, the exception should
* be rethrown so that the standard servlet error handling
* takes over.
*
* <p>
* 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.
*
* <p>
* 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.
*
* @param t the throwable to be handled
*
* @throws ServletException if an error occurs while invoking the error page
* @throws IOException if an I/O error occurred while invoking the error
* page
* @throws NullPointerException if the exception is null
*
* @see #handlePageException(Exception)
*/
abstract public void handlePageException(Throwable t)
throws ServletException, IOException;
/**
* 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.
*
* @return the new BodyContent
*/
public BodyContent pushBody() {
return null; // XXX to implement
}
/**
* Provides convenient access to error information.
*
* @return an ErrorData instance containing information about the
* error, as obtained from the request attributes, as per the
* Servlet specification. If this is not an error page (that is,
* if the isErrorPage attribute of the page directive is not set
* to "true"), the information is meaningless.
*
* @since 2.0
*/
public ErrorData getErrorData() {
return new ErrorData(
(Throwable)getRequest().getAttribute( "javax.servlet.error.exception" ),
((Integer)getRequest().getAttribute(
"javax.servlet.error.status_code" )).intValue(),
(String)getRequest().getAttribute( "javax.servlet.error.request_uri" ),
(String)getRequest().getAttribute( "javax.servlet.error.servlet_name" ) );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -