Forums Register Login

Clarification on Servlet Spec for URL Mapping

+Pie Number of slices to send: Send
Hi,
Can anybody explain me a bit on what they mean....
This is part of the chapter in servlet spec("Mapping Requests to Servlets")

2. The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the �/� character as a path separator. The longest match determines the servlet selected.
+Pie Number of slices to send: Send
<servlet-mapping>
<servlet-name>servlet1</servlet-name>
<url-pattern>/first/second/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>servlet2</servlet-name>
<url-pattern>/second/*</url-pattern>
</servlet-mapping>



if ur url is x/first/second/com.MyServlet
1. search for x/first/second/com.MyServlet pattern...NOT FOUND
2. search for /first/second/com.MyServlet pattern... FOUND

this maps to servlet1

if ur url is x/y/second/com.MyServlet
1. search for x/y/second/com.MyServlet ...pattern...NOT FOUND
2. search for /y/second/com.MyServlet ...pattern... NOTFOUND
3. search for /second/com.MyServlet ...pattern... FOUND

this maps to servlet2
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 474 times.
Similar Threads
url-pattern for directory match
Mapping Requests to Servlets
URL mapping confusion
filter mapping to servlets
Default servlet and static content
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:07:01.