by Kishan » Fri Feb 08, 2013 3:27 pm
Yes, you can define multiple servlet-mappings and url patterns for one servlet. It gives flexibility to invoke servlet with different url-patterns.
Example: If you have ItemServlet view item. Lets think seller can view item by calling ItemServlet, buyer can view item by calling ItemServlet. But I would like to access the servlet with different path info as below:
http://localhost:8080/ecommerce/buyeritem --- for buyer flow
http://localhost:8080/ecommerce/selleritem --- for seller flow
In the servlet processing logic might be different dependes what who is calling servlet i.e. buyer or seller. This information can be identified by calling request.getPathInfo() hence different logic executes who is invoking the servlet.
Not only this you can handle different filtering/authorization by having different mappings for the servlet.