"Lipner, Tomas" wrote:

> The below code runs servlet "myservlet" with pathinfo "pages/welcome.jsp".
> <frame NAME="main" SRC="<%= context %>/servlet/myservlet/pages/welcome.jsp"
> NORESIZE>
>
> It functions correctly with Tomcat 3.1, but Tomcat 3.2 returns error message
> "The page cannot be found".
> Tomcat 3.2 doesn't interpret it as 'myservlet' with path info
> 'pages/welcome.jsp', but wants to open page
> "/servlet/myservlet/pages/welcome.jsp" directly.
>

It looks like the change to an interceptor version of the invoker broke the
previous ordering of mapping a request URI to a servlet -- now it is picking up
the "*.jsp" match for the JSP servlet before checking for the path match.

Note that the "invoker" concept (/servlet/*) is not part of the servlet
specification, so you are not guaranteed that it will work identically -- or
even be present -- on any given servlet container.  As a portable mechanism to
do what you want, I suggest adding the following to your web.xml file:

    <servlet>
        <servlet-name>myservlet</servlet-name>
        <!-- Change this to the fully qualified class name of your servlet -->
        <servlet-class>myservlet</servlet-class>
    </servlet>

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

This inserts a path-based mapping back into the way Tomcat works, which occurs
ahead of the extension mapping (due to the rules in the servlet spec).  As an
extra added bonus, you can map this servlet to any URL you like -- it doesn't
have to start with "/servlet/myservlet" if you would prefer something else).



>
> When I use:
> /servlet/myservlet/servlet/anotherservlet
>
> it functions correctly, i.e. myservlet is called with path info
> 'servlet/anotherservlet'
>
> Tomas

Craig McClanahan


Reply via email to