• 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

Mapping client requests to resoures

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Here is a question on servlet mapping:
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?
<!-- 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>

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

The ans given is Rule 3 i-e VauxHallServlet.
It's obvious that 1 and 2 are incorrect.
But somehow, I can't figure out that why Rule 4 is not executed. Can anybody throw some light on this.

Thanks,
Reema
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The rules for servlet mapping

The container first look for exact match if cannot find the exact match it look for directory match and if it cannot find a directory match it look for extension match.

For this URI
/SCWCD/door/file.hall?
We have got the directory match
/door/*

so answer is VauxHallServlet
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic