• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url-pattern

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After passing some tests, i am having doubts regarding the tag <url-pattern> :
does it always have to start with a / , except in the case of an extension ?

<url-pattern> /bla </url-pattern> ok
<url-pattern> /bla/ </url-pattern> ok
<url-pattern> *.doc </url-pattern> ok
<url-pattern> /*.zip </url-pattern> ko
<url-pattern> /bla/*.do </url-pattern> ok
<url-pattern> /bla/ </url-pattern> ok
<url-pattern> /bla/* </url-pattern> ok
<url-pattern> bla </url-pattern> ko
<url-pattern> /*.* </url-pattern> ko
<url-pattern> bla1/bla2 </url-pattern> ok
[ November 17, 2006: Message edited by: Max Fernandes ]
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
find the answers for all url-patterns

<url-pattern> /bla </url-pattern> [correct][exact match]
<url-pattern> /bla/ </url-pattern> [correct][exact match]
<url-pattern> *.doc </url-pattern> [correct][extension match]
<url-pattern> /*.zip </url-pattern> [wrong]{must not start with slash}
<url-pattern> /bla/*.do </url-pattern>[wrong]{must be *.do}
<url-pattern> /bla/ </url-pattern> [correct][exact match]
<url-pattern> /bla/* </url-pattern>[correct][directory match]
<url-pattern> bla </url-pattern> [wrong]{must not start with slash}
<url-pattern> /*.* </url-pattern> [wrong]
<url-pattern> bla1/bla2 </url-pattern>[correct][exact match]

Hope this clarifies!!
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
So that means urls mappings to extensions must never start with a /
Please correct me if i am wrong.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your first question,
does it always have to start with a /


Container uses path for mapping a resource is:
SearchPattern = (request URL) - (Context Path) - (Query Strings);

So, for example,

Requested URL is: /rootContext/child1/login.do?admin="true"

Apply the above formula:

SearchPattern = (/rootContext/child1/login.do?admin="true") - (/rootContext) - (admin="true");

You will get searchPattern as: /child1/login.do

Pattern selected by container to search always starts with "/". So, <url-pattern> should also starts with "/".

For your second question,
urls mappings to extensions must never start with a /


Yes. Thats right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic