tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Terence M. Bandoian" <tere...@tmbsw.com>
Subject Re: RE: Static resource mapping in web.xml
Date Thu, 09 Jun 2011 18:56:35 GMT

On 1:59 PM, falvarez@geocom.com.uy wrote:
> 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,
> 	Federico.
>
> -----Mensaje original-----
> De: Christopher Schultz [mailto:chris@christopherschultz.net]
> Enviado el: jueves, 09 de junio de 2011 13:43
> Para: Tomcat Users List
> Asunto: Re: Static resource mapping in web.xml
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Federico,
>
> On 6/8/2011 2:04 PM, falvarez@geocom.com.uy 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 "*Servlet.java" | sed -e 's/\(.*\)\.java/<servlet>\n
> <servlet-name>\1<\/servlet-name>\n
> <servlet-class>\1<\/servlet-class>\n<\/servlet>\n\n<servlet-mapping>\n
> <servlet-name>\1<\/servlet-name>\n
> <url-pattern>\1<\/url-pattern>\n<\/servlet-mapping>/'
>
> 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
> names.
>
> 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
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk3w+CIACgkQ9CaO5/Lv0PAi+gCfYfLAaOJQIM0ziCbGOLN4eCno
> 4HYAoLLVVZQogmdMk1SzdXTpLEi9zbPm
> =/1
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Hi, Federico-

If I understand this correctly, and you're using ant, you should be able 
to strip '/servlet' from the servlet mappings by changing the uriroot 
attribute in the jasper2 task.

-Terence Bandoian



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message