JspRuntimeLibrary.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:lazycat 作者:
/**
 * Returns the value of the javax.servlet.error.exception request attribute
 * value, if present, otherwise the value of the
 * javax.servlet.jsp.jspException request attribute value.
 *
 * This method is called at the beginning of the generated servlet code for
 * a JSP error page, when the "exception" implicit scripting language
 * variable is initialized.
 */
public static Throwable getThrowable(ServletRequest request) {
    Throwable error = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
    if (error == null) {
        error = (Throwable) request.getAttribute(PageContext.EXCEPTION);
        if (error != null) {
            /*
             * The only place that sets JSP_EXCEPTION is
             * PageContextImpl.handlePageException(). It really should set
             * SERVLET_EXCEPTION, but that would interfere with the
             * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we need
             * to set SERVLET_EXCEPTION.
             */
            request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, error);
        }
    }

    return error;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号