You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ed...@SAAConsultants.com on 2000/06/19 20:10:42 UTC

Servlet mappings - and reading the spec isn't helping.

I have a mapping problem with tomcat 3.1, which I'm confused about in
relation to the 2.2 API spec. Please forgive the long-windedness of this
email, but I'm not sure what might be important.

My servlets are in packages which are all jar'd up with other classes, and
exist outside the tomcat directory structure. This doesn't appear to be a
problem - one of my servlets is automatically started up correctly by
tomcat.

tomcat's webserver is listening on 8080, and the ajp12 on 8007.

My servlet URI goes:

/path1/path2/servlet1/extra/bits

and I have another which goes:

/path1/path2/servlet2

(I have lots of servlets in the application, but I'm just concentrating on
two).

I wish to map any URL beginning with /path1/path2 to my web application,
and be more specific as to which servlet I invoke from there.

I have created a new web application in the default server called "app1".

My .....\webapps\app1\web-inf\web.xml has the following in it:

    <servlet>
        <servlet-name>servlet1</servlet-name>
        <servlet-class>com.saa.servlet1</servlet-class>
     <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>servlet1</servlet-name>
        <url-pattern>/path1/path2/servlet1/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>servlet2</servlet-name>
        <servlet-class>com.saa.servlet2</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>servlet2</servlet-name>
        <url-pattern>/path1/path2/servlet2</url-pattern>
    </servlet-mapping>

My .....\conf\server.xml has the following line:

    <Context path="/path1/path2" docBase="webapps/app1"
             defaultSessionTimeOut="30" isWARExpanded="true"
             isWARValidated="false" isInvokerEnabled="true"
             isWorkDirPersistent="false"/>


and my .....\conf\uriworkermap.properties has the following line:

/path1/path2/*=ajp12

Phew - now to the problem - I can't invoke it. If I try and connect to the
webserver port or tomcat direct:

http://host/path1/path2/servlet1/extra/bits
http://host:8080/path1/path2/servlet1/extra/bits

I get a 404.

My servlet2, that doesn't have any arguments after the servlet id, gives me
the same errors.

My mapping is obviously off target and I'd appreciate any help with this.
The 2.2 spec isn't helping, and all it's examples seem to have just one
level of nesting in the URI, not two like I have. And I get no error
information in tomcats logs with the default settings.

Regards

--------------------------------------------------------------------
Edward Williams, Principal Technical Consultant, SAA Consultants Ltd
web: www.saaconsultants.com
email: edward.williams@saaconsultants.com
phone: +44 (0) 1752 606000, fax: +44 (0) 1752 606838