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.
posted 11 years ago
/red/* in the servet mapping means : match anything that starts with "/red". Therefore "/colorapp/red" matches this pattern.