This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat - URL patterns

 
Hemant Kamat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a small problem with respect to the URL pattern behaviour in Tomcat (4.0) or even lower version.
e.g web.xml
<servlet-mapping>
<servlet-name>
snoop
</servlet-name>
<url-pattern>
/*.jsp
</url-pattern>
</servlet-mapping>
I have changed the URL pattern from /snoop to /*.jsp for the Snoop Servlet in the web.xml file (examples- default context).
Now when I enter http://localhost:8080/examples/abc.jsp
where abc.jsp may or may not be a valid resource, shouldn't the servlet container divert the request to the Snoop Servlet??
It dosen't in my case. Is there any other additional settings, because Professional JSP uses many such examples and I just can't seem to simulate them.
Only if I enter http://localhost:8080/examples/*.jsp does the SnoopServlet get invoked.
Can anyone explain this to me?
Isn't *.jsp supposed to invloke Snoop servlet for any jsp resource requested for the examples context?


------------------
 
Peter Masreblta
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Try to replace /*.jsp with *.jsp in <url-pattern>.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. To expand a bit: do not make the mistake of thinking that a servlet container has a full-featured wildcard matching facility for its URL mapping rules. That would - presumably - be too inefficient. It recognises only the following:
  • A path mapping of the form "/foo/bar/*", which must end in "/*".
  • An extension mapping of the form "*.foo", which must start with "*.".
  • The default mapping "/", which matches any request not matched by any other mapping.
  • Any other mapping will be interpreted as an exact match.
  • Your mapping did not match any of the first three cases and was interpreted as an exact match. What you wanted was an extension mapping which you'll get if you omit the leading "/".
    - Peter
 
Hemant Kamat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter,
Both of you. That clarified my problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic