• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ - Servlet Mapping Doubt

 
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
I have a doubt from the HFSJ about servlet mapping. Given the following DD,
which servlet container will choose. I answered all correctly except for these two.

1. http://localhost:8080/MapTest/fooStuff/bar/blue.do
Container choice: DeployTestThree

2. http://localhost:8080/MapTest/fooStuff/bar/foo.fo
Container choice: DeployTestThree

However, considering the servlet mapping rules of exact match, directory match and extension match,
I choose DeployTestTwo as answer since the exact match failed and directory match succeeded.

Is my understanding correct?


[/code]
 
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the answer for both is foo.DeployTestTwo ?
 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No! The correct answer is foo.DeployTestThree. I am wondering how?
 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think since the url pattern for DeployTestTwo servlet doesn't end with '/' the match failed. So only thing left is DeployTestThree.
Am I correct?
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sequence of matching is:-
1.exact matching
2.directory matching
3.extension matching.

Since the url is:
http://localhost:8080/MapTest/fooStuff/bar/blue.do
The exact match fails.
It looks for a directory match /fooStuff/* and the url satisfies this.so container chooses DeployTestThree.
The same is true with the url http://localhost:8080/MapTest/fooStuff/bar/foo.fo .

Also note: in url :http://localhost:8080/MapTest/fooStuff/bar/foo.fo
http:// is protocol.
//localhost:8080/ is server
/MapTest/fooStuff/bar/ is a path
and
foo.fo is a resource
If the url pattern would have been :
<url-pattern>/fooStuff/bar/*</url-pattern>

then it would have choosen the corresponding servlet of this pattern instead.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic