larryi 00/11/20 19:09:55
Modified: src/share/org/apache/jasper/runtime PageContextImpl.java
Log:
Port changes from tomcat_32 branch.
Fix for bug report #412:
public void removeAttribute(String name) does not work properly
- removeAttribute now removes the attribute from the 4 scopes.
- REQUEST_SCOPE now handled properly.
When "redirecting" to the error page in handlePageException(), first try to
forward to the error page.If this fails because the response has already
been committed, do an include of the error page instead -- that way the user
gets at least some feedback on what is causing the problem.
Revision Changes Path
1.17 +18 -8
jakarta-tomcat/src/share/org/apache/jasper/runtime/PageContextImpl.java
Index: PageContextImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PageContextImpl.java 2000/09/29 07:00:40 1.16
+++ PageContextImpl.java 2000/11/21 03:09:55 1.17
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
1.16 2000/09/29 07:00:40 costin Exp $
- * $Revision: 1.16 $
- * $Date: 2000/09/29 07:00:40 $
+ * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
1.17 2000/11/21 03:09:55 larryi Exp $
+ * $Revision: 1.17 $
+ * $Date: 2000/11/21 03:09:55 $
*
* ====================================================================
*
@@ -92,8 +92,6 @@
/**
* Implementation of the PageContext class from the JSP spec.
*
- * The removeAttribute method does not work for request scope. Needs fixing.
- *
* @author Anil K. Vijendran
* @author Larry Cable
* @author Hans Bergsten
@@ -289,7 +287,7 @@
break;
case REQUEST_SCOPE:
- throw new IllegalArgumentException("cant remove Attributes from
request scope");
+ request.removeAttribute(name);
case SESSION_SCOPE:
if (session == null)
@@ -370,7 +368,15 @@
}
public void removeAttribute(String name) {
- attributes.remove(name);
+ try {
+ removeAttribute(name, PAGE_SCOPE);
+ removeAttribute(name, REQUEST_SCOPE);
+ removeAttribute(name, SESSION_SCOPE);
+ removeAttribute(name, APPLICATION_SCOPE);
+ } catch (Exception ex) {
+ // we remove as much as we can, and
+ // simply ignore possible exceptions
+ }
}
public JspWriter getOut() {
@@ -439,7 +445,11 @@
request.setAttribute("javax.servlet.jsp.jspException", e);
if (errorPageURL != null && !errorPageURL.equals("")) {
- forward(errorPageURL);
+ try {
+ forward(errorPageURL);
+ } catch (IllegalStateException ise) {
+ include(errorPageURL);
+ }
} // Otherwise throw the exception wrapped inside a ServletException.
else {
// Set the exception as the root cause in the ServletException