tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54387] New: Having servlets with same url should at least cause warning
Date Tue, 08 Jan 2013 12:58:37 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54387

            Bug ID: 54387
           Summary: Having servlets with same url should at least cause
                    warning
           Product: Tomcat 7
           Version: 7.0.34
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: edsonrichter@hotmail.com
    Classification: Unclassified

I've found this interesting "mal functioning" in a application where I just
copied the mapping portion of web.xml for a new created servlet, but forgot to
change de URI.

Tomcat deployed the application without any warning, but when running the
application only the last referenced servlet was working (like if the mapping
of the first has been overwritten by the last in the XML file).

I made additional tests using annotations in servlets, and the behavior of
having more than one servlet with same mapping causes random access to one or
another (I cannot determine a predictable way).

In order to prevent breaking existing applications, I would like to have just a
"big warning" in the log at startup and/or deployment of the application that
have more than one servlet mapped to same URL.

Examples of the problem:

Example 1: Web.xml
...
  <servlet>
    <servlet-name>PrintDacteServlet</servlet-name>
    <servlet-class>br.com.simfreteV1.web.PrintDacteServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>CotacaoReportServlet</servlet-name>
    <servlet-class>br.com.simfreteV1.web.CotacaoReportServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>PrintDacteServlet</servlet-name>
    <url-pattern>/secure/relatorios/Action</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>CotacaoReportServlet</servlet-name>
    <url-pattern>/secure/relatorios/Action</url-pattern>
  </servlet-mapping>
...


Example 2: annotations in java servlet files

@WebServlet(name = "PdfReportPrint", urlPatterns =
{"/secure/relatorios/doReport"})
public class PdfReportPrint extends AbstractBaseServlet {
...


@WebServlet(name = "PrintBoletoServlet", urlPatterns =
{"/secure/relatorios/doReport"})
public class PrintBoletoServlet extends HttpServlet {
...

-- 
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


Mime
View raw message