• 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

j2eecertification.com question

 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kedar,

Thanks for the explanation!

Really helpful.

Kapil
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic