larryi 00/11/10 18:56:58
Modified: src/share/org/apache/tomcat/context Tag: tomcat_32
DefaultCMSetter.java
src/share/org/apache/tomcat/core Tag: tomcat_32
ContextManager.java Handler.java Response.java
ResponseImpl.java
Log:
Restored display of the actual error location for included servlets in the
default output.
Note: These internal locations are only displayed if setDebugInfo="true" for
the ContextManager in server.xml
Revision Changes Path
No revision
No revision
1.45.2.8 +10 -9
jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
Index: DefaultCMSetter.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
retrieving revision 1.45.2.7
retrieving revision 1.45.2.8
diff -u -r1.45.2.7 -r1.45.2.8
--- DefaultCMSetter.java 2000/11/09 21:42:46 1.45.2.7
+++ DefaultCMSetter.java 2000/11/11 02:56:57 1.45.2.8
@@ -216,6 +216,7 @@
throws Exception
{
String msg=(String)req.getAttribute("javax.servlet.error.message");
+ String errorURI = res.getErrorURI();
Throwable e= (Throwable)req.
getAttribute("tomcat.servlet.error.throwable");
@@ -230,7 +231,7 @@
StringBuffer buf = new StringBuffer();
buf.append("<h1>");
- if( res.isIncluded() ) {
+ if( errorURI != null ) {
buf.append(sm.getString("defaulterrorpage.includedservlet") ).
append(" ");
} else {
@@ -247,12 +248,11 @@
.append(req.getRequestURI())
.append("</h2>");
- if ( res.isIncluded() && contextM.getShowDebugInfo()) {
+ if ( errorURI != null && contextM.getShowDebugInfo()) {
buf.append("\r\n<h2>")
.append(sm.getString("defaulterrorpage.errorlocation"))
.append(" ")
- .append((String)req.
- getAttribute("javax.servlet.include.request_uri"))
+ .append(errorURI)
.append("</h2>");
}
@@ -329,6 +329,7 @@
throws Exception
{
String msg=(String)req.getAttribute("javax.servlet.error.message");
+ String errorURI = res.getErrorURI();
res.setContentType("text/html");
// res is reset !!!
@@ -337,7 +338,8 @@
StringBuffer buf = new StringBuffer();
buf.append("<head><title>");
- if( res.isIncluded() ) {
+ // if an included request originated
+ if( errorURI != null ) {
// use error code from include
sc =
((Integer)req.getAttribute("javax.servlet.error.status_code")).intValue();
buf.append(sm.getString("defaulterrorpage.includedservlet") );
@@ -349,7 +351,7 @@
buf.append("</title></head>\r\n");
buf.append("<h1>");
- if( res.isIncluded() ) {
+ if( errorURI != null ) {
buf.append(sm.getString("defaulterrorpage.includedservlet") )
.append(" ");
} else {
@@ -366,12 +368,11 @@
.append(req.getRequestURI())
.append("</h2>");
- if ( sc >= 400 && res.isIncluded() && contextM.getShowDebugInfo()) {
+ if ( sc >= 400 && errorURI != null && contextM.getShowDebugInfo()) {
buf.append("\r\n<h2>")
.append(sm.getString("defaulterrorpage.errorlocation"))
.append(" ")
- .append((String)req.
- getAttribute("javax.servlet.include.request_uri"))
+ .append(errorURI)
.append("</h2>");
}
No revision
No revision
1.100.2.18 +5 -8
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
Index: ContextManager.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
retrieving revision 1.100.2.17
retrieving revision 1.100.2.18
diff -u -r1.100.2.17 -r1.100.2.18
--- ContextManager.java 2000/11/10 06:42:48 1.100.2.17
+++ ContextManager.java 2000/11/11 02:56:58 1.100.2.18
@@ -994,6 +994,11 @@
// -------------------- Error handling --------------------
+ public void saveErrorURI( Request req, Response res ) {
+ if (res.getErrorURI() == null)
+ res.setErrorURI(
(String)req.getAttribute("javax.servlet.include.request_uri"));
+ }
+
/** Called for error-codes
*/
public void handleStatus( Request req, Response res, int code ) {
@@ -1060,9 +1065,6 @@
* or use the default handler.
*/
void handleError( Request req, Response res , Throwable t ) {
- // if error already handled
- if (res.isErrorHandled())
- return;
Context ctx = req.getContext();
if(ctx==null) {
ctx=getContext("");
@@ -1084,8 +1086,6 @@
req.setAttribute("tomcat.servlet.error.unavailableTime", new
Integer(unavailableTime));
res.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); // 503
handleStatus( req, res, HttpServletResponse.SC_SERVICE_UNAVAILABLE );
- // indicate error handling has been called
- res.setErrorHandled(true);
return;
}
else if( t instanceof IllegalStateException ) {
@@ -1152,9 +1152,6 @@
} catch( ServletException e) {
; // ASSERT: Only thrown by included servlets
}
-
- // indicate error handling has been called
- res.setErrorHandled(true);
}
public ServletWrapper getHandlerForPath( Context ctx, String path ) {
1.7.2.7 +7 -3 jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
retrieving revision 1.7.2.6
retrieving revision 1.7.2.7
diff -u -r1.7.2.6 -r1.7.2.7
--- Handler.java 2000/11/10 02:06:32 1.7.2.6
+++ Handler.java 2000/11/11 02:56:58 1.7.2.7
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.6
2000/11/10 02:06:32 craigmcc Exp $
- * $Revision: 1.7.2.6 $
- * $Date: 2000/11/10 02:06:32 $
+ * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.7
2000/11/11 02:56:58 larryi Exp $
+ * $Revision: 1.7.2.7 $
+ * $Date: 2000/11/11 02:56:58 $
*
* ====================================================================
*
@@ -260,6 +260,8 @@
}
context.log("Exception in init " + ex.getMessage(), ex );
if (res.isIncluded()) { // Only propogate on includes
+ // save error URI if necessary
+ contextM.saveErrorURI( req, res );
if (ex instanceof IOException)
throw (IOException) ex;
else if (ex instanceof ServletException)
@@ -294,6 +296,8 @@
// Rethrow the exception if we are inside an include
if (res.isIncluded()) {
+ // save error URI if necessary
+ contextM.saveErrorURI( req, res );
// context.log("Rethrowing doService exception: " + t);
if (t instanceof IOException)
throw (IOException) t;
1.22.2.2 +7 -7 jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
Index: Response.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -u -r1.22.2.1 -r1.22.2.2
--- Response.java 2000/11/09 13:31:35 1.22.2.1
+++ Response.java 2000/11/11 02:56:58 1.22.2.2
@@ -143,15 +143,15 @@
*/
public void setIncluded(boolean b);
- /** True if error has been handled
+ /** Saves the request that originates an error.
*/
- public boolean isErrorHandled();
-
- /** This is used to indicate that error handling has been performed.
- * It is used to avoid invoking the error handling more than once
- * as exceptions are passed up the call stack.
+ public void setErrorURI(String uri) ;
+
+ /** This is used to retrieve the included request that
+ * originated an error when the error is handled at the
+ * top level request.
*/
- public void setErrorHandled(boolean b);
+ public String getErrorURI() ;
// -------------------- Buffering --------------------
1.33.2.4 +9 -9
jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java
Index: ResponseImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
retrieving revision 1.33.2.3
retrieving revision 1.33.2.4
diff -u -r1.33.2.3 -r1.33.2.4
--- ResponseImpl.java 2000/11/09 13:31:35 1.33.2.3
+++ ResponseImpl.java 2000/11/11 02:56:58 1.33.2.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
1.33.2.3 2000/11/09 13:31:35 larryi Exp $
- * $Revision: 1.33.2.3 $
- * $Date: 2000/11/09 13:31:35 $
+ * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
1.33.2.4 2000/11/11 02:56:58 larryi Exp $
+ * $Revision: 1.33.2.4 $
+ * $Date: 2000/11/11 02:56:58 $
*
* ====================================================================
*
@@ -108,7 +108,7 @@
protected boolean commited = false;
boolean notIncluded=true;
- boolean errorHandled=false;
+ String errorURI=null;
// default implementation will just append everything here
StringBuffer body=null;
@@ -157,12 +157,12 @@
}
}
- public boolean isErrorHandled() {
- return errorHandled;
+ public void setErrorURI(String uri) {
+ errorURI = uri;
}
- public void setErrorHandled( boolean handled ) {
- errorHandled = handled;
+ public String getErrorURI() {
+ return errorURI;
}
public boolean isStarted() {
@@ -184,7 +184,7 @@
started = false;
commited = false;
notIncluded=true;
- errorHandled=false;
+ errorURI=null;
// adapter
body=null;
if( out != null ) out.recycle();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]