Bug 52530 - Incorrectly accept many url-pattern on a single servlet-mapping in web.xml
Incorrectly accept many url-pattern on a single servlet-mapping in web.xml
Status: RESOLVED WONTFIX
Product: Tomcat 5
Classification: Unclassified
Component: Unknown
5.5.26
PC Linux
: P2 enhancement (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-01-25 21:29 UTC by Giuseppe Sacco
Modified: 2012-01-26 11:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giuseppe Sacco 2012-01-25 21:29:39 UTC
Dear tomcat developers,
I need to map the same servlet on two different url. I used netbeans 7.0.1 for managing my whole project, so I used its friendly interface to modify the web.xml file. What netbeans created is this:

<servlet-mapping>
    <servlet-name>fred</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>/url</url-pattern>
</servlet-mapping>

This is read by tomcat 5.5 without emitting any error, but only the second pattern works, while the first one is ignored.

Googling I found that the right way for tomcat 5.5 is this one:

<servlet-mapping>
    <servlet-name>fred</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>fred</servlet-name>
    <url-pattern>/url</url-pattern>
</servlet-mapping>

And this seems to be right way because tomcat 5.5 is bound to Servlet 2.4.

Spec for Servlet 2.5, on note SRV.19.0.3 titled «Multiple Occurrences of Servlet Mappings», says:

    Previous versions of the servlet schema allows only a single url-pattern or servlet name per servlet mapping. For servlets mapped to multiple URLs this results in needless repetition of whole mapping clauses.

So, I think tomcat 5.5 should emit an error for this broken web.xml file.

Thanks,
Giuseppe
Comment 1 Konstantin Kolinko 2012-01-25 23:06:00 UTC
1. Tomcat 5.5 implements Servlet Specification 2.4 [1]
The syntax you tried to use was introduced in 2.5.
2. Tomcat 5.5 is near its end of life. New features won't be implemented.
3. Tomcat 7 does validation of web.xml against schema if you enable STRICT_SERVLET_COMPLIANCE mode.

[1] http://tomcat.apache.org/whichversion.html
Comment 2 Giuseppe Sacco 2012-01-26 08:29:11 UTC
Hi Konstantin,
thanks for your quick reply. I am unsure about the reason for marking it RESOLVED and INVALID, since I think the problem is still there. Let's recap what you wrote:

> 1. Tomcat 5.5 implements Servlet Specification 2.4 [1]
> The syntax you tried to use was introduced in 2.5.

Ok, this is what I already wrote in my report.

> 2. Tomcat 5.5 is near its end of life. New features won't be implemented.

This is something new for me. Is there any date for ending support on tomcat 5.5?
Is a bugfix really cataloged as "new feature"?

> 3. Tomcat 7 does validation of web.xml against schema if you enable
> STRICT_SERVLET_COMPLIANCE mode.

I don't need web.xml validation, and I am not using tomcat7. So this is useless.

If you really think this is a minor bug and do not want to fix it because tomcat 5.5 is not end of life, just mark it as VERIFIED and WONTFIX.

Thanks,
Giuseppe
Comment 3 Konstantin Kolinko 2012-01-26 11:15:16 UTC
(In reply to comment #2)
> > 2. Tomcat 5.5 is near its end of life. New features won't be implemented.
> 
> This is something new for me. Is there any date for ending support on tomcat
> 5.5?

It is mentioned in many places. Direct link:

http://tomcat.apache.org/tomcat-55-eol.html

> Is a bugfix really cataloged as "new feature"?

If you deploy a broken web application, the behaviour might be undefined.