You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/11/04 17:32:54 UTC

DO NOT REPLY [Bug 52138] New: global web.xml servlet-mappings are not used when additional mappings are defined in app web.xml

https://issues.apache.org/bugzilla/show_bug.cgi?id=52138

             Bug #: 52138
           Summary: global web.xml servlet-mappings are not used when
                    additional mappings are defined in app web.xml
           Product: Tomcat 7
           Version: 7.0.22
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: james_defelice@elementk.com
    Classification: Unclassified


In my application web.xml I define a servlet-mapping for a new extension:

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

I have not modified, in any way, the global web.xml file.

The application context is loaded just fine, but .jsp files are not handled by
the JspServlet (which is declared in global web.xml).  The end result being
that the JSP source code is served to a web client instead of HTML generated by
a compiled jsp class.

.jsp files are compiled if I add the following to my web.xml:

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

However, this seems redundant since that mapping is declared already in the
global web.xml file.  My expectation was that the global mappings would be
merged with the application mappings at deploy time -- which does not seem to
be happening in this case.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52138] global web.xml servlet-mappings are not used when additional mappings are defined in app web.xml

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52138

James DeFelice <ja...@elementk.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #2 from James DeFelice <ja...@elementk.com> 2011-11-06 21:29:43 UTC ---
Servlets defined in global web.xml are inherited by webapp web.xml.  New
servlets defined in web.xml do not eliminate servlets declared in global
web.xml, instead they are merged - this spares the app developer from needing
to declare the JspServlet, DefaultServlet, etc. in their webapp web.xml files
alongside their proprietary servlet declarations.

Mappings defined in global web.xml are also inherited, by default, in the
webapp. However, if new mappings are added in web.xml, then global web.xml
mappings are dropped. Web developers that want to add new mappings for servlets
declared in global web.xml are forced to re-declare the mappings in their
webapp web.xml because they are not automatically inherited.

Why would the design of servlet declaration inheritance be out of sync with the
design of servlet mapping inheritance?  Especially since servlet and servlet
mapping declarations have such a close relationship?

This behavior seems inconsistent at best.  I'd like to understand the rationale
behind this design decision, and how this does not constitute a design bug.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52138] global web.xml servlet-mappings are not used when additional mappings are defined in app web.xml

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52138

--- Comment #4 from Mark Thomas <ma...@apache.org> 2011-11-08 23:41:16 UTC ---
To expand on my previous comment...

When servlet mappings are overridden (e.g. fragment overrides annotations, or
application overrides global) all servlet mappings from the overridden source
are dropped. The reason for this is simple. If annotations are used to map a
servlet to *.foo but the developer wants to change that to *.bar, there is no
way to explicitly remove one or more mappings. Therefore, all overridden
mappings are removed. The price that is paid for this is that if a developer
wants to add a mapping, they have to specify all the overridden mappings as
well.

This behaviour has been confirmed as required and correct with the Servlet EG
for fragments, annotations and main web.xml. The global defaults just follow
this pattern.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52138] global web.xml servlet-mappings are not used when additional mappings are defined in app web.xml

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52138

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #3 from Konstantin Kolinko <kn...@gmail.com> 2011-11-06 21:35:05 UTC ---
WONTFIX

There is nothing wrong with redeclaring standard servlets and mappings when you
need to customize them. (That was always the case as far as I remember since
5.5).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52138] global web.xml servlet-mappings are not used when additional mappings are defined in app web.xml

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52138

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Mark Thomas <ma...@apache.org> 2011-11-04 19:33:10 UTC ---
The current behaviour is by design.

The Servlet specification doesn't cover global defaults but Tomcat's behaviour
is line with the rest of the Servlet specification.

For example, if mappings are provided for a Servlet in annotations and in the
main web.xml they are not additive. Only the ones from the main web.xml are
used. The full precedence order is:
main web.xml > fragments > annotations > defaults

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org