On Mon, 31 Dec 2001, Lai Kok Cheong wrote:

> Date: Mon, 31 Dec 2001 16:29:19 +0800
> From: Lai Kok Cheong <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: URL string not supported
>
>        I suspect tomcat 4.01 does not support below URL format :-
>       http://www.server.com/TestServlet/paramone/paramtwo/paramthree
>
>       TestServlet is the servlet
>       paramone , paramtwo and paramthree is a parameter passed to
> TestServlet
>
>       but when I tested with other servlet engine i could run.
>
>       my
>       webapps/test/WEB-INF/web.xml
>       extract
>          <servlet>
>             <servlet-name>
>               vl
>             </servlet-name>
>             <servlet-class>
>                        a.b.c.TestServlet
>             </servlet-class>
>           </servlet>
>
>       could anyone verify this ?
>

In order for this to work, you also need a servlet mapping that attaches
the path "/TestServlet" to your servlet.  Like this:

    <servlet-mapping>
        <servlet-name>vl</servlet-name>
        <url-pattern>/TestServlet/*</url-pattern>
    </servlet-mapping>

Then (assuming you install this as the ROOT webapp), the URL:

    http://www.server.com/TestServlet/paramone/paramtwo/paramthree

will indeed be processed by your servlet.  It will see the following
values:

    request.getServletPath() will return "/TestServlet"
    request.getPathInfo() will return "/paramone/paramtwo/paramthree"

All the rules for servlet mappings and how they work (which is exactly
what Tomcat does :-) are in the servlet specification, which you can
download at <http://java.sun.com/products/servlet/download.html>.

Craig McClanahan


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to