You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fu...@apache.org on 2004/09/27 18:04:05 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardHostValve.java
funkman 2004/09/27 09:04:05
Modified: webapps/docs changelog.xml
catalina/src/share/org/apache/catalina/core
StandardHostValve.java
Log:
When looking for error pages based on status, first check that the
response was in error.
Revision Changes Path
1.119 +11 -5 jakarta-tomcat-catalina/webapps/docs/changelog.xml
Index: changelog.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- changelog.xml 27 Sep 2004 15:31:27 -0000 1.118
+++ changelog.xml 27 Sep 2004 16:04:04 -0000 1.119
@@ -28,13 +28,19 @@
<section name="Tomcat 5.5.3 (yoavs)">
<subsection name="General">
- <fix>
- <bug>30568</bug>: Incomplete setup.html documentation for launching jsvc. (yoavs)
- </fix>
+ <fix>
+ <bug>30568</bug>: Incomplete setup.html documentation for launching jsvc. (yoavs)
+ </fix>
</subsection>
<subsection name="Catalina">
<changelog>
+ <fix>
+ When checking status codes for error handling, only check if
+ Response.isError() is true. This way, users may use setStatus() to set their own
+ error status without having the error page invoked. (in which case, the user should've
+ use sendError()) (funkman)
+ </fix>
<update>
Remove Digester code for Xerces workaround. (jfarcand)
</update>
@@ -51,9 +57,9 @@
<fix>
<bug>31277</bug>: Clarified automatic application deployment section of Host configuration page. (yoavs)
</fix>
- <fix>
+ <fix>
<bug>28631</bug>: JAASRealm enhancements to support custom user and role classes use Commons-Logging. (yoavs)
- </fix>
+ </fix>
<fix>
<bug>31364</bug>: Missing resource in org.apache.catalina.core.LocalString.properties. (yoavs)
</fix>
1.24 +27 -18 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostValve.java
Index: StandardHostValve.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostValve.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- StandardHostValve.java 7 Jul 2004 16:32:59 -0000 1.23
+++ StandardHostValve.java 27 Sep 2004 16:04:05 -0000 1.24
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2001,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -121,7 +121,7 @@
Thread.currentThread().setContextClassLoader
(context.getLoader().getClassLoader());
}
-
+
// Ask this Context to process this request
context.getPipeline().getFirst().invoke(request, response);
@@ -162,15 +162,15 @@
Context context = request.getContext();
if (context == null)
return;
-
+
Throwable realError = throwable;
-
+
if (realError instanceof ServletException) {
realError = ((ServletException) realError).getRootCause();
if (realError == null) {
realError = throwable;
}
- }
+ }
// If this is an aborted request from a client just log it and return
if (realError instanceof ClientAbortException ) {
@@ -202,10 +202,10 @@
realError);
Wrapper wrapper = request.getWrapper();
if (wrapper != null)
- request.setAttribute(Globals.SERVLET_NAME_ATTR,
+ request.setAttribute(Globals.SERVLET_NAME_ATTR,
wrapper.getName());
request.setAttribute(Globals.EXCEPTION_PAGE_ATTR,
- request.getRequestURI());
+ request.getRequestURI());
request.setAttribute(Globals.EXCEPTION_TYPE_ATTR,
realError.getClass());
if (custom(request, response, errorPage)) {
@@ -218,7 +218,7 @@
} else {
// A custom error-page has not been defined for the exception
// that was thrown during request processing. Check if an
- // error-page for error code 500 was specified and if so,
+ // error-page for error code 500 was specified and if so,
// send that page back as the response.
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// The response is an error
@@ -226,7 +226,7 @@
status(request, response);
}
-
+
}
@@ -249,12 +249,21 @@
if (context == null)
return;
+ /* Only look for error pages when isError() is set.
+ * isError() is set when response.sendError() is invoked. This
+ * allows custom error pages without relying on default from
+ * web.xml.
+ */
+ if (!response.isError())
+ return;
+
ErrorPage errorPage = context.findErrorPage(statusCode);
if (errorPage != null) {
response.setAppCommitted(false);
request.setAttribute(Globals.STATUS_CODE_ATTR,
new Integer(statusCode));
- String message = RequestUtil.filter(response.getMessage());
+
+ String message = RequestUtil.filter(response.getMessage());
if (message == null)
message = "";
request.setAttribute(Globals.ERROR_MESSAGE_ATTR, message);
@@ -263,14 +272,14 @@
errorPage.getLocation());
request.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
new Integer(ApplicationFilterFactory.ERROR));
-
-
+
+
Wrapper wrapper = request.getWrapper();
if (wrapper != null)
- request.setAttribute(Globals.SERVLET_NAME_ATTR,
+ request.setAttribute(Globals.SERVLET_NAME_ATTR,
wrapper.getName());
request.setAttribute(Globals.EXCEPTION_PAGE_ATTR,
- request.getRequestURI());
+ request.getRequestURI());
if (custom(request, response, errorPage)) {
try {
response.flushBuffer();
@@ -341,7 +350,7 @@
Integer statusCodeObj =
(Integer) request.getAttribute(Globals.STATUS_CODE_ATTR);
int statusCode = statusCodeObj.intValue();
- String message =
+ String message =
(String) request.getAttribute(Globals.ERROR_MESSAGE_ATTR);
response.reset(statusCode, message);
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org