Bug 50153 - Remapping the default servlet
Summary: Remapping the default servlet
Status: RESOLVED DUPLICATE of bug 50026
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.4
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-25 16:57 UTC by bozho
Modified: 2010-10-26 08:46 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bozho 2010-10-25 16:57:41 UTC
Since I'm using a framework that maps its own servlet to /*, I have to remap the default servlet. In Tomcat 7.0.0 this mapping was working:

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

But it doesn't in Tomcat 7.0.4

I also tried /static/* - same result.

(The way it doesn't work is by serving 404)
Comment 1 Chuck Caldarale 2010-10-25 22:56:58 UTC
(In reply to comment #0)
> Since I'm using a framework that maps its own servlet to /*, I have to remap
> the default servlet. In Tomcat 7.0.0 this mapping was working:
> 
>    <servlet-mapping>
>         <servlet-name>default</servlet-name>
>         <url-pattern>/static/</url-pattern>
>    </servlet-mapping>
> 
> But it doesn't in Tomcat 7.0.4

Unfortunately, you have been taking advantage (?) of a security hole in the default servlet that allowed an ill-specified <url-pattern> to serve static content from arbitrary locations.  As noted in the 7.0 changelog, the related bug report can be found here:

http://issues.apache.org/bugzilla/show_bug.cgi?id=50026

The normal way to correctly implement this is to place the static content under a known, real location, and configure that in <url-pattern>.  Alternatively, a filter can be used to detect static references and forward them to the DefaultServlet.  One could also use the appropriate suffix notation in the <url-pattern> to direct requests to the DefaultServlet.

 - Chuck
Comment 2 Mark Thomas 2010-10-26 08:46:27 UTC

*** This bug has been marked as a duplicate of bug 50026 ***