craigmcc 01/07/16 21:21:15
Modified: catalina/src/share/org/apache/catalina Globals.java
catalina/src/share/org/apache/catalina/core
ApplicationDispatcher.java
StandardWrapperValve.java
catalina/src/share/org/apache/catalina/servlets
InvokerServlet.java
jasper/src/share/org/apache/jasper Constants.java
jasper/src/share/org/apache/jasper/servlet JspServlet.java
tester/src/tester/org/apache/tester ErrorPage06.java
tester/web ErrorPage06.jsp
Log:
Correct the handling of <jsp-file> declarations in the web.xml file.
Previously, the way this was mapped to Jasper involved modifying the
request URI and servlet path of the request. Now, the name of the actual
page to be executed is passed as a request attribute
("org.apache.catalina.jsp_file") instead.
PR: BugTraq #4458252, Bugzilla #2613
Revision Changes Path
1.28 +13 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java
Index: Globals.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Globals.java 2001/05/15 03:25:47 1.27
+++ Globals.java 2001/07/17 04:21:12 1.28
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
1.27 2001/05/15 03:25:47 craigmcc Exp $
- * $Revision: 1.27 $
- * $Date: 2001/05/15 03:25:47 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
1.28 2001/07/17 04:21:12 craigmcc Exp $
+ * $Revision: 1.28 $
+ * $Date: 2001/07/17 04:21:12 $
*
* ====================================================================
*
@@ -69,7 +69,7 @@
* Global constants that are applicable to multiple packages within Catalina.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.27 $ $Date: 2001/05/15 03:25:47 $
+ * @version $Revision: 1.28 $ $Date: 2001/07/17 04:21:12 $
*/
public final class Globals {
@@ -156,6 +156,15 @@
*/
public static final String ERROR_MESSAGE_ATTR =
"javax.servlet.error.message";
+
+
+ /**
+ * The request attribute under which we expose the value of the
+ * <code><jsp-file></code> value associated with this servlet,
+ * if any.
+ */
+ public static final String JSP_FILE_ATTR =
+ "org.apache.catalina.jsp_file";
/**
1.21 +14 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
Index: ApplicationDispatcher.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ApplicationDispatcher.java 2001/07/16 22:24:12 1.20
+++ ApplicationDispatcher.java 2001/07/17 04:21:12 1.21
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
1.20 2001/07/16 22:24:12 craigmcc Exp $
- * $Revision: 1.20 $
- * $Date: 2001/07/16 22:24:12 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
1.21 2001/07/17 04:21:12 craigmcc Exp $
+ * $Revision: 1.21 $
+ * $Date: 2001/07/17 04:21:12 $
*
* ====================================================================
*
@@ -105,7 +105,7 @@
* <code>javax.servlet.ServletResponseWrapper</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.20 $ $Date: 2001/07/16 22:24:12 $
+ * @version $Revision: 1.21 $ $Date: 2001/07/17 04:21:12 $
*/
final class ApplicationDispatcher
@@ -627,6 +627,11 @@
// Call the service() method for the allocated servlet instance
try {
+ String jspFile = wrapper.getJspFile();
+ if (jspFile != null)
+ request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
+ else
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
if (servlet != null) {
if ((hrequest != null) && (hresponse != null)) {
servlet.service((HttpServletRequest) request,
@@ -635,20 +640,25 @@
servlet.service(request, response);
}
}
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
} catch (IOException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("applicationDispatcher.serviceException",
wrapper.getName()), e);
ioException = e;
} catch (UnavailableException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("applicationDispatcher.serviceException",
wrapper.getName()), e);
servletException = e;
wrapper.unavailable(e);
} catch (ServletException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("applicationDispatcher.serviceException",
wrapper.getName()), e);
servletException = e;
} catch (RuntimeException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("applicationDispatcher.serviceException",
wrapper.getName()), e);
runtimeException = e;
1.27 +14 -21
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java
Index: StandardWrapperValve.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- StandardWrapperValve.java 2001/05/16 17:56:11 1.26
+++ StandardWrapperValve.java 2001/07/17 04:21:12 1.27
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
1.26 2001/05/16 17:56:11 remm Exp $
- * $Revision: 1.26 $
- * $Date: 2001/05/16 17:56:11 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
1.27 2001/07/17 04:21:12 craigmcc Exp $
+ * $Revision: 1.27 $
+ * $Date: 2001/07/17 04:21:12 $
*
* ====================================================================
*
@@ -103,7 +103,7 @@
* <code>StandardWrapper</code> container implementation.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.26 $ $Date: 2001/05/16 17:56:11 $
+ * @version $Revision: 1.27 $ $Date: 2001/07/17 04:21:12 $
*/
final class StandardWrapperValve
@@ -184,23 +184,6 @@
if (sres instanceof HttpServletResponse)
hres = (HttpServletResponse) sres;
- // HOLD YOUR NOSE - Kludge to deal with <jsp-file> servlets.
- // Modify the request paths for a servlet that was defined
- // with a <jsp-file> element instead of a <servlet-class>.
- String jspFile = wrapper.getJspFile();
- if ((hreq != null) && (hres != null) && (jspFile != null)) {
- StringBuffer sb = new StringBuffer();
- String contextPath = hreq.getContextPath();
- if (contextPath != null)
- sb.append(contextPath);
- sb.append(jspFile);
- String pathInfo = hreq.getPathInfo();
- if (pathInfo != null)
- sb.append(pathInfo);
- ((HttpRequest) request).setRequestURI(sb.toString());
- ((HttpRequest) request).setServletPath(jspFile);
- }
-
// Check for the application being marked unavailable
if (!((Context) wrapper.getParent()).getAvailable()) {
hres.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
@@ -251,26 +234,36 @@
// Call the filter chain for this request
// NOTE: This also calls the servlet's service() method
try {
+ String jspFile = wrapper.getJspFile();
+ if (jspFile != null)
+ sreq.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
+ else
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
if ((servlet != null) && (filterChain != null)) {
filterChain.doFilter(sreq, sres);
}
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
} catch (IOException e) {
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
; // No reporting to the response
; // No change in availability status
} catch (UnavailableException e) {
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
exception(request, response, e);
wrapper.unavailable(e);
} catch (ServletException e) {
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
exception(request, response, e);
} catch (Throwable e) {
+ sreq.removeAttribute(Globals.JSP_FILE_ATTR);
log(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
1.7 +13 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java
Index: InvokerServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- InvokerServlet.java 2001/07/17 00:14:17 1.6
+++ InvokerServlet.java 2001/07/17 04:21:13 1.7
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
1.6 2001/07/17 00:14:17 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/07/17 00:14:17 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
1.7 2001/07/17 04:21:13 craigmcc Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/07/17 04:21:13 $
*
* ====================================================================
*
@@ -86,7 +86,7 @@
* in the web application deployment descriptor.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/07/17 00:14:17 $
+ * @version $Revision: 1.7 $ $Date: 2001/07/17 04:21:13 $
*/
public final class InvokerServlet
@@ -418,8 +418,15 @@
// Invoke the service() method of the allocated servlet
try {
+ String jspFile = wrapper.getJspFile();
+ if (jspFile != null)
+ request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
+ else
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
instance.service(wrequest, response);
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
} catch (IOException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
try {
wrapper.deallocate(instance);
} catch (Throwable f) {
@@ -427,6 +434,7 @@
}
throw e;
} catch (ServletException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
try {
wrapper.deallocate(instance);
} catch (Throwable f) {
@@ -434,6 +442,7 @@
}
throw e;
} catch (RuntimeException e) {
+ request.removeAttribute(Globals.JSP_FILE_ATTR);
try {
wrapper.deallocate(instance);
} catch (Throwable f) {
1.11 +10 -0
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/Constants.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Constants.java 2001/03/21 20:49:07 1.10
+++ Constants.java 2001/07/17 04:21:13 1.11
@@ -109,6 +109,16 @@
/**
* FIXME
+ * Request attribute for <code><jsp-file></code> element of a
+ * servlet definition. If present on a request, this overrides the
+ * value returned by <code>request.getServletPath()</code> to select
+ * the JSP page to be executed.
+ */
+ public static final String JSP_FILE = "org.apache.catalina.jsp_file";
+
+
+ /**
+ * FIXME
* ServletContext attribute for classpath. This is tomcat specific.
* Other servlet engines can choose to have this attribute if they
* want to have this JSP engine running on them.
1.19 +3 -0
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java
Index: JspServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JspServlet.java 2001/06/12 09:08:25 1.18
+++ JspServlet.java 2001/07/17 04:21:14 1.19
@@ -428,6 +428,9 @@
jspUri = request.getServletPath();
else
jspUri = includeUri;
+ String jspFile = (String) request.getAttribute(Constants.JSP_FILE);
+ if (jspFile != null)
+ jspUri = jspFile;
boolean precompile = preCompile(request);
1.5 +3 -3
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java
Index: ErrorPage06.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ErrorPage06.java 2001/05/10 20:45:52 1.4
+++ ErrorPage06.java 2001/07/17 04:21:14 1.5
@@ -67,7 +67,7 @@
* the ErrorPage05 servlet returns the appropriate exception.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2001/05/10 20:45:52 $
+ * @version $Revision: 1.5 $ $Date: 2001/07/17 04:21:14 $
*/
public class ErrorPage06 extends HttpServlet {
@@ -140,8 +140,8 @@
String request_uri = (String) value;
String test1 = request.getContextPath() + "/ErrorPage05";
String test2 = request.getContextPath() + "/WrappedErrorPage05";
- String test3 = request.getContextPath() + "/ErrorPage08.jsp";
- String test4 = request.getContextPath() + "/WrappedErrorPage08.jsp";
+ String test3 = request.getContextPath() + "/ErrorPage08";
+ String test4 = request.getContextPath() + "/WrappedErrorPage08";
if (!request_uri.equals(test1) && !request_uri.equals(test2) &&
!request_uri.equals(test3) && !request_uri.equals(test4)) {
sb.append(" request_uri is ");
1.4 +2 -2 jakarta-tomcat-4.0/tester/web/ErrorPage06.jsp
Index: ErrorPage06.jsp
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/ErrorPage06.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ErrorPage06.jsp 2001/05/10 20:45:56 1.3
+++ ErrorPage06.jsp 2001/07/17 04:21:15 1.4
@@ -53,8 +53,8 @@
String request_uri = (String) value;
String test1 = request.getContextPath() + "/ErrorPage05";
String test2 = request.getContextPath() + "/WrappedErrorPage05";
- String test3 = request.getContextPath() + "/ErrorPage08.jsp";
- String test4 = request.getContextPath() + "/WrappedErrorPage08.jsp";
+ String test3 = request.getContextPath() + "/ErrorPage08";
+ String test4 = request.getContextPath() + "/WrappedErrorPage08";
if (!request_uri.equals(test1) && !request_uri.equals(test2) &&
!request_uri.equals(test3) && !request_uri.equals(test4)) {
sb.append(" request_uri is ");