2012/11/13 Fred Toth <ft...@synernet.com>:
> On 11/12/2012 4:24 PM, Konstantin Kolinko wrote:
>>
>> 2012/11/13 Fred Toth <ft...@synernet.com>:
>>>
>>> Hello again,
>>>
>>> I've found my problem, sort of.
>>>
>>> In this particular application, ever since tomcat 5, we've been remapping
>>> the DefaultServlet url-pattern. Works fine in 5 and 6, but not in 7.
>>> Which
>>> means I've got another problem, but at least I know why the app fails to
>>> run.
>>>
>>> Here's the problem bit from my web.xml:
>>>
>>>      <servlet-mapping>
>>>          <servlet-name>default</servlet-name>
>>>          <url-pattern>/default/*</url-pattern>
>>>      </servlet-mapping>
>>>
>>> The idea here is to be able to do access control at the struts level, but
>>> then to be able to forward to DefaultServlet so that it can do what it
>>> does
>>> best (like serving PDFs, for example). I'm not sure why having this setup
>>> in
>>> tomcat 7 causes my app to fail completely, but taking this out cures the
>>> core problem. URLs start working properly, but now I have access control
>>> problems that were solved by the above.
>>>
>> It was a change to fix an issue important for security. See
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=50026
>>
>>
>> If you just need to forward to the servlet, do you need to map it to
>> different path?
>> It is possible to select the servlet by its name,
>> ServletContext.getNamedDispatcher("default").forward(..)
>>
>> Best regards,
>> Konstantin Kolinko
>>
>
> Thanks for the pointer, Konstantin. This helps me understand the issues.
> However, any idea why that mapping should cause my entire app to fail? The
> forwards to "/default" happen only in fairly restricted circumstances. Why,
> for example, would this cause failures to serve everything else?
>
> To be more specific: We're serving *.html with struts2 and this has nothing
> to do with DefaultServlet. Yet somehow having that mapping in place breaks
> the whole thing.
>
> I'll try your suggestion (forwarding to DefaultServlet without the mapping)
> tomorrow.
>

It looks like it overrides the default mapping of this servlet. If I
add the above fragment to web.xml of the docs application, I get 404
in Tomcat 7, while in Tomcat 6 it works.

If I replace above with the following, it works in Tomcat 7:

 <servlet-mapping>
   <servlet-name>default</servlet-name>
   <url-pattern>/default/*</url-pattern>
   <url-pattern>/</url-pattern>
 </servlet-mapping>

(Well, I do not know your whole web.xml. Just trying/guessing what it might be.)

Servlet Spec 3.0 defines how web.xml fragments are merged. The
algorithm is a bit complicated. This affects how the global web.xml is
merged with webapp's one. (The change in the order of filters is one
known example mentioned in Migration Guide).

BTW, the effective merged web.xml can be printed into the log. There
is an attribute on <Context> that enables such logging.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to