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

HFSJ - Servlet Mapping Doubt

 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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]
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the answer for both is foo.DeployTestTwo ?
 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No! The correct answer is foo.DeployTestThree. I am wondering how?
 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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?
 
Niteen Patil
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic