Reputation: 20946
Im not sure that its possible to do what I want to accomplish. I want to map one single servlet to two different URL.
I want both http://10.0.0.1/a and http://10.0.0.1/b to map to the same servlet.
I know its possibe to do the following in web.xml;
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/b</url-pattern>
</servlet-mapping>
But that enables the following url: http://10.0.0.1/ContextPath/b/
Upvotes: 2
Views: 1842
Reputation: 30448
You can do the following:
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/a</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/b</url-pattern>
</servlet-mapping>
And then both http://host/webapp/a and http://host/webapp/b will be mapped to the same servlet.
If you want to drop the /webapp prefix, you need to set your web app as the ROOT by setting the path attribtue of the context to "" in your context xml file (under webapps or in META-INF/context.xml)
Upvotes: 6