URL Pattern
- url pattern of a servlet is very much useful to hide servlet class name from the end user of web application to generate register to servlet web resource program from browser window
- according to sun Microsystems there are three types of url pattern programmer can chose any one types of url pattern while providing url pattern to the servlet
- while giving request to servlet web resources program the end user must know url pattern of the servlet
- 3 types of url pattern
o Exact match
§ In this style of url pattern multiple words can be there separate with slash ‘/’ symbol, but the symbol star ‘*’ must not appears in the url pattern
<servlet>
<servlet-name> ABC</servlet-name>
<servlet –class> DateSrv</servlet-class>
<servlet-mapping >
<servlet-name> ABC</servlet-name>
<Url-pattern> /test/xyz</url-pattern>
</servlet-mapping >
§ Example url: from browser window
§ Other exact match url pattern example
· <url-pattern>/test</url-pattern>
· <url-pattern>/test/xyz./abc</url-pattern>
· <url-pattern>/ab/xyz/123</url-pattern>
· <url-pattern>/a</url-pattern>
· <url-pattern>/abv/xyz.test.c</url-pattern>
§ By taking the support of those sensible url pattern we can hide the technology name of servlet web resource from end user of web application
o Directory match
§ Contain * symbol at the end of the url pattern words and url pattern can contain one / more words in it
§ Example : <url-pattern>/x/y/*</url-pattern>, in this example x, y are directory and * symbol must be write
§ * symbol represents zero/ more char presence/ words presence
§ Example urls:
· http://localhost:2020/DateApp/x/y x/y valid
· http://localhost:2020/DateApp/x/z/abc in valid
· http://localhost:2020/DateApp/a/b/x/y in valid
· http://localhost:2020/DateApp/px/y/z/abc/xyz in valid
o Extension match
§ in extension match url pattern the sybols * must be the first character of url pattern and the extension can be any word/letter
<url-pattern>*.xyz</url-pattern>
§ example urls:
· http://localhost:2020/DateApp/abc.xyz valid
· http://localhost:2020/DateApp/xyz/test/abcxyz valid
-