Well, simply map all 3 of them in the web.xml
and deploy them. Below, a sample web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>com.acme.Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>com.acme.Servlet2</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet3</servlet-name>
<servlet-class>com.acme.Servlet3</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/path1/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/path2/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet3</servlet-name>
<url-pattern>/path3/*</url-pattern>
</servlet-mapping>
</web-app>
Note that the following URLs (assuming mycontext
is the context):
Match the pattern <url-pattern>/path1/*</url-pattern>
(so you don't need to map them on /path1, /path1/*).
If you are using Eclipse WTP, you can register Tomcat as a Server and deploy your Dynamic Web Project on it from Eclipse (right-click on the project and select Run As > Run on Server).
Outside Eclipse, you'll have to package your application as a .war
(the standard format for a webapp) and deploy this war on Tomcat. There are several ways to do this but the most straightforward way is to copy the war into $TOMCAT_HOME/webapps
.