Types of URL pattern supported by Tomcat
This tutorial will walk through about how many types of URL pattern supported by Tomcat server or container. Tomcat is most popular and widely used servlet container by the Java developer. Tomcat container will support 3 type of URL pattern.
Character Sequence Match
In this type of URL pattern matching, the request will match the complete character of the action.
<servlet>
<servlet-name>register</servlet-name>
<servlet-class>org.websparrow.RegisterAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>register</servlet-name>
<url-pattern>/registerEmployee</url-pattern>
</servlet-mapping>In this case, only a request from registerEmployee action will be handled by RegisterAction servlet but if RegisterAction handles multiple registrations, you need to map all them and it will increase the size of the deployment descriptor and complexity.
Expression or Directory Match
Expression or directory math type URL pattern matches the directory and expression.
<servlet>
<servlet-name>register</servlet-name>
<servlet-class>org.websparrow.RegisterAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>register</servlet-name>
<url-pattern>/emp/*</url-pattern>
</servlet-mapping>In this case, RegisterAction servlet handles all request from emp directory. This type of URL pattern is suitable for a single MVC framework application.
Extension Match
Extention match URL pattern is recommended by the industry. It matches the extension of the URL.
<servlet>
<servlet-name>register</servlet-name>
<servlet-class>org.websparrow.RegisterAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>register</servlet-name>
<url-pattern>/emp/*.action</url-pattern>
</servlet-mapping>In this case, RegisterAction servlet will handle all those URLs which have the action extension from emp directory. You can integrate the multiple MVC framework together.
Similar Posts
- How to install Maven in Eclipse IDE
- How to search Java, JSP file in Eclipse IDE?
- How to enable breadcrumb in Eclipse/STS
- How to search old emails in Gmail quickly
- svn: There are unfinished transactions detected
- Maven- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- wamp- Could not execute menu item (internal error): The service has not been started
- Create a Data Source in JasperReports Server
- How to customize command prompt in Windows 7?
- Why physical memory usage so high in Windows 7?