"foo.jsp/" in the url is treated as a resource!?? [message #87155] |
Fri, 27 April 2007 14:03 |
Sasa Teofanovic Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Hi,
I've registered the JspServlet (org.eclipse.equinox.jsp.jasper) to the
HttpService with the alias "*.jsp", but if someone requests the page with
a slash at the end (".../foo.jsp/), the jsp page is treated as a resource,
because all my resources are mapped with "/". However, in this case there
should be thrown a PAGE_NOT_FOUND (like Tomcat does it).
I'm running Tomcat 5.5 as my web container and its "DefaultServlet"
handles these requests in its serveResource() method as follows:
protected void serveResource(HttpServletRequest request,
HttpServletResponse response,
boolean content) throws IOException, ServletException {
...
// If the resource is not a collection, and the resource path
// 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,
requestUri);
return;
}
}
...
}
It seems that, there's any code analysing the requested path in the jsp
equinox bundle!?? So unfortunately, i was forced to implement it for
myself by catching the request in the handleSecurity() method of my
HttpContext:
public boolean handleSecurity(HttpServletRequest request,
HttpServletResponse response) throws IOException {
if(delegate.handleSecurity(request, response)) {
String path = request.getPathInfo();
if(path == null || path.length() == 0) {
path = request.getRequestURI();
}
if(path.endsWith("/") || path.endsWith("\\")) {
response.sendError(HttpServletResponse.SC_NOT_FOUND,
path);
return false;
}
return true;
}
return false;
}
Is this a known or new bug, or did I make something wrong??
thx,
teos
|
|
|
Re: "foo.jsp/" in the url is treated as a resource!?? [message #87190 is a reply to message #87155] |
Fri, 27 April 2007 14:28 |
Simon Kaegi Messages: 381 Registered: July 2009 |
Senior Member |
|
|
Hi teos,
What version of the components are you using? I just tried this use-case
with HEAD and it indeed maps to a resource however it returns a 404 for me.
Could you see if you can reproduce this with the current code.
-Simon
"teos" <sasa.teofanovic@gmx.at> wrote in message
news:2c4491d0d7419c0dbe95f910bb0c7a06$1@www.eclipse.org...
> Hi,
>
> I've registered the JspServlet (org.eclipse.equinox.jsp.jasper) to the
> HttpService with the alias "*.jsp", but if someone requests the page with
> a slash at the end (".../foo.jsp/), the jsp page is treated as a resource,
> because all my resources are mapped with "/". However, in this case there
> should be thrown a PAGE_NOT_FOUND (like Tomcat does it).
>
> I'm running Tomcat 5.5 as my web container and its "DefaultServlet"
> handles these requests in its serveResource() method as follows:
>
> protected void serveResource(HttpServletRequest request,
> HttpServletResponse response,
> boolean content) throws IOException, ServletException {
>
> ..
>
> // If the resource is not a collection, and the resource path
> // 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,
> requestUri);
> return;
> }
> }
>
> ..
>
> }
>
> It seems that, there's any code analysing the requested path in the jsp
> equinox bundle!?? So unfortunately, i was forced to implement it for
> myself by catching the request in the handleSecurity() method of my
> HttpContext:
>
> public boolean handleSecurity(HttpServletRequest request,
> HttpServletResponse response) throws IOException {
>
> if(delegate.handleSecurity(request, response)) {
> String path = request.getPathInfo();
> if(path == null || path.length() == 0) {
> path = request.getRequestURI();
> }
> if(path.endsWith("/") || path.endsWith("\\")) {
> response.sendError(HttpServletResponse.SC_NOT_FOUND,
> path);
> return false;
> }
> return true;
> }
> return false;
>
> }
>
> Is this a known or new bug, or did I make something wrong??
>
> thx,
> teos
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03091 seconds