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

url-pattern with slash

 
Renata fonseca
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I�d like to know the difference between:
-
<servlet-mapping>
<servlet-name>someName</servlet-name>
<url-pattern>/someUrl</url-pattern>
</servlet-mapping>
-
AND...
-
<servlet-mapping>
<servlet-name>someName</servlet-name>
<url-pattern>someUrl</url-pattern>
</servlet-mapping>
-
Are there any difference?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Renata,
I guess /someUrl in the first case represents the relative path, whereas
someUrl in the second case represents the absolute path(like c:\Jrun\..blah blah) of the resource.
-Harneet
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried both ways in weblogic server 6.1 and I was able to access the web app successfully. I don't think the url-pattern with out a / in front represents any absoulte path. I like to hear some more explanation
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few rules about how to specify and interpret the contents of the <url-pattern> tag:
1) If the servlet path specified starts with a "/" and ends "/*", the container will recursively step through the request URI path a directory at a time until a match is found. For example:

2) If the request URI contains an extension (eg. *.jsp), then the container will find a match if a url-pattern exists for that extension. For example:

3) All other url-patterns are exact matches only (ie. those that don't start and end with "/" and "/*", or "*.aaa). The container only finds a match if the request URI matches the pattern exactly. For example:

Soooo...
If I've got it right, the example you provided applies to point 3) above. If your request URI is /myApplication/someUrl, an exact match is found for both of your servlet mappings:

Clear as mud?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic