tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Static resource mapping in web.xml
Date Thu, 09 Jun 2011 18:15:03 GMT
Yes, we would probably use some tools to build the web.xml.

Currently our applications has something between 10000 to 15000 servlets.

Mapping to "/servlet/*" how it works now, a normal URL is "http://host:8080/webapp/servlet/myservlet".
But then I tried to remove the "/servlet/" from the URL, that's when all this trouble began.

> Don't map to "/*" of course: instead map to a specific URL.

	My intention is to map "myservlet" to "/myservlet", for example. This removes any aditional
string in the URL. So the UR becomes: "http://host:8080/webapp/myservlet".

The application works fine with this new invoker mapping, the only "problem" is that resources
are served under "/images/images/*". This impacts in many servlets that have hard-coded access
to images, javascripts or css files (I know how bad this is), also others have relative links
that now don't work. Most do have a parameter pointing to the right resource folder and work
fine, but finding the ones causing trouble is not easy.

The "excuse" or "reason" I've been getting when this matter is addressed is the ease of deployment
the invoker provides.

I will be building a testing environment a few days from now, using a proper web.xml and no
invoker. Guess my job now will be to demonstrate the advantages of this (the URL improvement
will be the easiest for them to see). Of course for this matter to succeed the creation of
a fully automated web.xml building script will be required.

Thanks for the help.

Best regards,

-----Mensaje original-----
De: Christopher Schultz [] 
Enviado el: jueves, 09 de junio de 2011 13:43
Para: Tomcat Users List
Asunto: Re: Static resource mapping in web.xml

Hash: SHA1


On 6/8/2011 2:04 PM, wrote:
> If this is the case I could make it weight-in in the matter of building a
> well formed web.xml.
> Although it could take some time.

How many servlets do you have?

> Mapping each servlet to an "/*" url-pattern will avoid us from using invoker
> and at the same time get rid of "/servlet" in the URL and keep images under
> "/images".

Don't map to "/*" of course: instead map to a specific URL.

You can use some simple tools to generate the mappings. Something like this:

$ find -name "*" | sed -e 's/\(.*\)\.java/<servlet>\n

Obviously, you'll have top massage some of that: the servlet-class needs
to be dot-separated the the above command will give you slash-separated

You'll also have to separate the <servlet> and <servlet-mapping>
sections ... or just run two separate commands: one to generate the
<servlet> elements and the other to generate the <servlet-mapping> elements.

Removing the invoker servlet and just explicitly mapping everything is
only a /little/ tedious but much safer. Take the time to do this now.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message