tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: URL pattern rules in web.xml
Date Mon, 10 Apr 2000 16:27:33 GMT
Randall Parker wrote:

> I have this URL:
>    webapps/info/GetPicture/teamtopdir/bauer1.jpg
> I have a servlet called PictureGetter that is supposed to get this URL's request.
> The "webapps" part is the context path in the server.xml:
>         <Context path="/webapps" docBase="iscribe"
>             defaultSessionTimeOut="30" isWARExpanded="true"
>             isWARValidated="false" isInvokerEnabled="true"
>             isWorkDirPersistent="false"/>

Note that setting the context path to "/webapps" means that all requests
to servlets in this webapp need to start with "/webapps", which is
probably not what you intended.  See below for more.

> Then I have the following in web.xml for the info/GetPicture and the rest:
>     <servlet>
>         <servlet-name>
>             GetPicture
>         </servlet-name>
>         <servlet-class>
>             sitemgmt.PictureGetter
>         </servlet-class>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>
>             GetPicture
>         </servlet-name>
>         <url-pattern>
>             /info/GetPicture/*
>         </url-pattern>
>     </servlet-mapping>
> Is this the right URL Pattern to use? Or should I go /*/* or something else?

It's not what you wanted.  The URL pattern you specified above (based on
the <Context> entry as well) will respond to:


type requests -- the "/webapps" is there because of the context path. 
You probably want to replace the mapping for the default context
instead, because it's context path is "/".  That way, the URL
pattern will match


as you wanted.

> Also, since my main page URL is mapped to port 8080 (I'm not going thru Apache). But
I'm using relative URL addresses within the document. Will they all use port 8080 if the main
page uses port
> 8080? That happens with my links that are href links. So I'd expect it to happen for
IMG SRC links.

Relative URLs are resolved on the *client* side (based on the absolute
URL of the page doing the reference) and then converted to absolute URLs
that are sent to the servlet container.  For example,
if you had a page in the document root of your app (in directory
"iscribe"), it would refer to an image accessed through your servlet
with the relative URL "info/GetPicture/something.jpg".  If you
had a subdirectory under "iscribe" and wanted to use a relative URL, it
would be "../info/GetPicture/something.jpg".

> Anyway, my PictureGetter servlet is not seeing any requests. Anyone have any guesses
as to why?

Craig McClanahan

View raw message