| Author |
Three question about Servlet Mapping
|
Hai Lin
Ranch Hand
Joined: May 23, 2004
Posts: 79
|
|
Hi Folks, Suppose there's a web application called colorapp. then in the web.xml, <servlet-mapping> <servlet-name>RedServlet</servlet-name> <url-pattern>/red/*</url-pattern> </servlet-mapping> The book SCWCD exam study kid said "URI /colorapp/red will match RedServlet." But I have doubt: The url-pattern is /red/*, that means at least URI should end with "/", so why /colorapp/red can match it? If we say the last "/" in url-pattern doesn't matter, then take a look the following mapping, <servlet-mapping> <servlet-name>BlueServlet</servlet-name> <url-pattern>/blue/</url-pattern> </servlet-mapping> The URI /colorapp/blue doesn't match BlueServlet, That means the last "/" in the servlet mapping is very important! So, my confusion is that 1) why the first mapping /colorapp/red is fine? 2) how about /colorapp/red/? 3) any "?" used in the url-pattern mapping? Greatly appreciate your reply.
|
 |
dick dijk
Greenhorn
Joined: Jan 19, 2004
Posts: 5
|
|
/red/* in the servet mapping means : match anything that starts with "/red". Therefore "/colorapp/red" matches this pattern. Dick
|
 |
 |
|
|
subject: Three question about Servlet Mapping
|
|
|