webtier@glassfish.java.net

mapping a servlet to '/'

From: <webtier_at_javadesktop.org>
Date: Tue, 08 Sep 2009 14:44:00 PDT

Hi!

I would like to have my 'dispatcher servlet' mapped to '/',
so that the following link will hit it:

http://host:port/application/

Setting the mapping to '/' does it but, to my surprise, links
like the following will also hit it:

http://host:port/application/ANYTHING_EXCEPT_FOR_A_DIFFERENT_SERVLET_MAPPING_HITS_THE_DISPATCHER_SERVLET

What is the difference between using '/' and '/*' then? Shouldn't '/' work just for http://host:port/application/ and '/*' for http://host:port/application/ or http://host:port/application/ANYTHING?

This mapping behaviour makes it difficult to include a .css file in the html generated by the servlet. Any link referring to it e.g:

http://host:port/application/somepath/mycss.css

returns the 'dispatcher servlet' instead of the .css file.
[Message sent by forum member 'dziku' (kpach_at_poczta.onet.pl)]

http://forums.java.net/jive/thread.jspa?messageID=363289