luehe 2004/10/14 16:58:38
Modified: catalina/src/share/org/apache/catalina/servlets
DefaultServlet.java
Log:
Expose any errors on an included resource.
For example, a JSP with this include action:
<jsp:include page="nonexistent">
or
<jsp:include page="nonexistent.jsp">
where nonexistent[.jsp] does not exist, currently returns silently, hiding the
fact that the resource to be included does not exist.
This patch returns a 404 with the name of the nonexistent resource.
Yes, SRV.8.3 ("The Include Method") mentions that
"it [the target servlet] cannot set headers or call any method that
affects the headers of the response. Any attempt to do so must be
ignored."
but i don't think it is referring to the error case.
Let me know if you see any problems.
Revision Changes Path
1.29 +22 -8
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
Index: DefaultServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- DefaultServlet.java 19 Sep 2004 01:20:10 -0000 1.28
+++ DefaultServlet.java 14 Oct 2004 23:58:38 -0000 1.29
@@ -281,12 +281,12 @@
protected String getRelativePath(HttpServletRequest request) {
// Are we being processed by a RequestDispatcher.include()?
- if (request.getAttribute("javax.servlet.include.request_uri")!=null) {
- String result = (String)
- request.getAttribute("javax.servlet.include.path_info");
+ if (request.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
+ String result = (String) request.getAttribute(
+ Globals.INCLUDE_PATH_INFO_ATTR);
if (result == null)
- result = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
+ result = (String) request.getAttribute(
+ Globals.INCLUDE_SERVLET_PATH_ATTR);
if ((result == null) || (result.equals("")))
result = "/";
return (result);
@@ -651,8 +651,15 @@
CacheEntry cacheEntry = resources.lookupCache(path);
if (!cacheEntry.exists) {
+ // Check if we're included so we can return the appropriate
+ // missing resource name in the error
+ String requestUri = (String) request.getAttribute(
+ Globals.INCLUDE_REQUEST_URI_ATTR);
+ if (requestUri == null) {
+ requestUri = request.getRequestURI();
+ }
response.sendError(HttpServletResponse.SC_NOT_FOUND,
- request.getRequestURI());
+ requestUri);
return;
}
@@ -660,8 +667,15 @@
// ends with "/" or "\", return NOT FOUND
if (cacheEntry.context == null) {
if (path.endsWith("/") || (path.endsWith("\\"))) {
+ // Check if we're included so we can return the appropriate
+ // missing resource name in the error
+ String requestUri = (String) request.getAttribute(
+ Globals.INCLUDE_REQUEST_URI_ATTR);
+ if (requestUri == null) {
+ requestUri = request.getRequestURI();
+ }
response.sendError(HttpServletResponse.SC_NOT_FOUND,
- request.getRequestURI());
+ requestUri);
return;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]