| - Context path - | - servlet path - | --PATH INFO - |
http://www.myserver.com / MyWebapp / Helloservlet / Hello
| -------- Request URI ---------------------------- |
Remember the following three points:. 1 Request URI = context path servlet path path info.2 Context paths and servlet paths start with a / but do not end with it.3 HttpServletRequest provides three methods getContextPath (), getServletPath (.. ) and getpathinfo () to Retrieve the Context path, The servlet path, and the path info, respective, associated with a request.
Identifying the servlet pathTo match a request URI with a servlet, the servlet container follows a simple algorithm.Once it identifies the context path, if any, it evaluates the remaining part of therequest URI with the servlet mappings specified in the deployment descriptor, in thefollowing ORDER. IF IT FINDS A Match At Any Step, IT Does Not Take The Next Step.
1 The container tries to match the request URI to a servlet mapping. If it finds amatch, the complete request URI (except the context path) is the servlet path. Inthis case, the path info is null.2 It tries to recursively match the longest path by stepping down the request uRIpath tree a directory at a time, using the / character as a path separator, and determiningif there is a match with a servlet. If there is a match, the matching partof the request URI is the servlet path and the remaining part is the path info.3 If the last node of the request URI contains an extension (.jsp, for example), the servlet container tries to match it to a servlet that handles requests for thespecified extension. In this case, the complete request URI is the servlet pathand the path info is null.4 If the container is still unable to find a match, it will forward the request to thedefault servlet. If there is no default servlet, it will send an error message indicatingthe servlet Was Not Found.
/ servlet-mapping>
Explain: Three errors here are wrong on Blue, pay attention to Blue's mapping url is / blue / instead / blue or / blue / * This is the main reason for causing errors