• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFSJ - Servlet Mapping Doubt

 
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • 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]
 
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 Tomcat Server Java
  • 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 Tomcat Server Java
  • 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?
 
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.
 
    Bookmark Topic Watch Topic
  • New Topic