• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

j2eecertification.com question

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
though i choose correct option..but i didn't get the explanation well..
kindly clear the explanation..
in following question..


Consider the following code-snippet in the deployment-descriptor from the web-application SCWCD. To which rule will the following request URI map: /SCWCD/door/file.hall?



1. Rule 1.
2. Rule 2.
3. Rule 3.
4. Rule 4.
5. Default servlet



<!-- Rule 1 --><servlet-mapping> <servlet-name>VauxHallServlet</servlet-name> <url-pattern>/hall/*</url-pattern></servlet-mapping><!-- Rule 2 --><servlet-mapping> <servlet-name>VauxHallServlet</servlet-name> <url-pattern>/hall/hall/*</url-pattern></servlet-mapping><!-- Rule 3 --><servlet-mapping> <servlet-name>VauxHallServlet</servlet-name> <url-pattern>/door/*</url-pattern></servlet-mapping><!-- Rule 4 --><servlet-mapping> <servlet-name>VauxHallServlet</servlet-name> <url-pattern>*.hall</url-pattern></servlet-mapping>





Feedback:
Answer 3 is correct.
The request URI: /SCWCD/door/file.hall can be split-up in different parts. The context path is /SCWCD, the servlet path is /door and the path-info is file.hall.
The servlet container tries to match the longest path to the servlet mapping, the servlet container uses the "/" separator to determine if a match can be found. If the servlet container cannot find a rule that matches it goes a directory below the hierarchy.
In this case the longest match is /door and Rule 3 is used. The extension match occurs only when the servlet path does not match any of the rules.
 
Kedar Dravid
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container looks for matching servlet mapping in this order:

First, exact match - Not applicable in the example.
Next, directory match - Rule 3 in the example.
Finally, extension match - Rule 4 in the example.

So, obviously rule 3 is the correct answer.
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kedar,

Thanks for the explanation!

Really helpful.

Kapil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic