SECTION: 500-Servlets TITLE: Path Mapping QUESTION: How are Servlet paths mapped? Path mappings are used to map a URI to a contexts, handlers and servlets. <BR><BR> The following types of mapping are supported and applied in the order presented. <BR><BR> <B>Absolute Mapping</B> <CODE><PRE>Path Spec: /path <BR><BR> Will match: /path path=/path info=<null> <BR><BR> Will not match: / /path/ /path/info /path/info.jsp /other </PRE></CODE> <B>Prefix Mapping</B> <CODE><PRE>Path Spec: /path/* <BR><BR> Will match: /path path=/path info=<null> /path/ path=/path info=/ /path/info path=/path info=/info /path/info.jsp path=/path info=/info.jsp <BR><BR> Will not match: / /other </PRE></CODE> <B>Suffix Mapping</B> <CODE><PRE>Path Spec: *.jsp <BR><BR> Will match: /path/info.jsp path=/path/info.jsp info=<null> <BR><BR> Will not match: / /path /path/ /path/info /other </PRE></CODE> <B>Default Mapping</B> <CODE><PRE>Path Spec: / <BR><BR> Will match: / path= info=/ /path path= info=/path /path/ path= info=/path/ /path/info path= info=/path/info /path/info.jsp path= info=/path/info.jsp /other path= info=/other <BR><BR> Will not match: </PRE></CODE><HR> <B>Typical examples</B> <BR><BR> <EM>Context and Servlet with path</EM><CODE><PRE> Context Path Spec : /context/* Servlet Path Spec : /servlet/* <BR><BR> URI <A HREF="ContextPath.html">ContextPath</A> <A HREF="ServletPath.html">ServletPath</A> <A HREF="PathInfo.html">PathInfo</A> ========================================================= /context/servlet /context /servlet null /context/servlet/ /context /servlet / /context/servlet/x /context /servlet /x </PRE></CODE> <BR><BR> <EM>Default Context</EM><CODE><PRE> Context Path Spec : / Servlet Path Spec : /servlet/* <BR><BR> URI <A HREF="ContextPath.html">ContextPath</A> <A HREF="ServletPath.html">ServletPath</A> <A HREF="PathInfo.html">PathInfo</A> ========================================================= /servlet "" /servlet null /servlet/ "" /servlet / /servlet/x "" /servlet /x </PRE></CODE> <BR><BR> <EM>Context and Suffix Servlet</EM><CODE><PRE> Context Path Spec : /context/* Servlet Path Spec : *.txt <BR><BR> URI <A HREF="ContextPath.html">ContextPath</A> <A HREF="ServletPath.html">ServletPath</A> <A HREF="PathInfo.html">PathInfo</A> ========================================================= /context/xxx.txt /context "" /xxx.txt </PRE></CODE> <BR><BR> <EM>Context and Default Servlet</EM><CODE><PRE> Context Path Spec : /context/* Servlet Path Spec : / <BR><BR> URI <A HREF="ContextPath.html">ContextPath</A> <A HREF="ServletPath.html">ServletPath</A> <A HREF="PathInfo.html">PathInfo</A> ========================================================= /context/xxx /context "" /xxx </PRE></CODE> <BR><BR> <EM>Default Context and Servlet</EM><CODE><PRE> Context Path Spec : / Servlet Path Spec : / <BR><BR> URI <A HREF="ContextPath.html">ContextPath</A> <A HREF="ServletPath.html">ServletPath</A> <A HREF="PathInfo.html">PathInfo</A> ========================================================= /xxx "" "" /xxx </PRE></CODE>