jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: welcome files and filters

From: Greg Wilkins <gregw_at_intalio.com>
Date: Fri, 29 Jun 2012 16:47:08 +0200

On 29 June 2012 09:46, Remy Maucherat <rmaucher_at_redhat.com> wrote:
> On Fri, 2012-06-29 at 00:15 -0700, Rajiv Mordani wrote:
>> Mark has filed an issue on JIRA -
>> http://java.net/jira/browse/SERVLET_SPEC-7 which basically is about
>> clarifying the behavior for filters with welcome files. In the example
>> with the filed issue - he has
>>
>> If a user requests "/foo" and "/foo" is a directory, the welcome files
>> "index.jsp" and "index.html" are configured and "index.html" is
>> present then what is compared against the filter mappings. Is it
>> "/foo" or "/foo/index.html".
>>
>> The suggestion is to go with the filter mapping should  be compared
>> to /foo/index.html and not /foo.
>
> Welcome files are not specified as a request dispatcher forward done by
> the default servlet, or anything similar,

Well the spec says in 10.10:
 "The container may send the request to the welcome resource with a
forward, a redirect, or a container specific mechanism that is
indistinguishable from a direct request"

> so it is (relatively) obvious
> to me that the request gets modified before going into the webapp, which
> means all it sees is the full welcome path ("/foo/index.html"). So
> filters use that as well.

So I agree that filters will see /foo/index.html in the redirect and
CSMTIIFADR case. But the filter might not even be invoked for a
forward, but if it is, then the paths are well defined anyway.




>> I think that this is a reasonable expectation - what do others think?
>> However the question that I have (and I don't think this is clarified
>> in the spec either) is what happens in the case where there is no
>> welcome file and the default servlet is invoked. Should the filter
>> mapping in that case be compared to /foo or /foo/<DefaultServlet>. I
>> think it should still be /foo/<DefaultServlet> but would like to get
>> input from others.
>
> If there's no welcome file, I don't see why the path should be modified.
> I don't understand what "/foo/<DefaultServlet>" means actually
> ("/foo/" ?).

I agree.... except in this scenario, the spec says that if there are
no static resources matching, then it searches for a matching servlet
mapping. This in this example the JSP servlet will probably be
invoked with /foo/index.jsp as the path


>> Comments / Suggestions?
>
> If the existing container behavior changes, that will probably beak
> things.

I think the welcome file mechanism is broken in all but the simplest
cases anyway :(



-- 
Greg Wilkins <gregw_at_intalio.com>
www.webtide.com
Developer advice, services and support
from the Jetty & CometD experts.