Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Tomcat - URL patterns

 
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?


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

Try to replace /*.jsp with *.jsp in <url-pattern>.
 
author
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.
 
I am displeased. You are no longer allowed to read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic