• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubts on Servlet mapping

 
Gopi Chand
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlet-pattern servlet
*.do servlet1
/path/* servlet2

if the request servlet is /path/hello.do, which servlet will be invoked? How it is decided? Is it in the order in which it is defined?
[ June 25, 2007: Message edited by: Bear Bibeault ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second servlet would be selected as because its the longest matching URL.

In the servlet sepcification its mentioned as how to decide on this.Order does not matter as only one servlet is selected in this process.
 
bnkiran kumar
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the following rules, first container checks for exact match, then directory match, then extension match. In your case as directory match occured, second one will be called.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jcoder:
How it is decided? Is it in the order in which it is defined?


Section SRV.11.1 in the servlet specification spells out the rules for pattern matching.
There is a link to the Servlet spec in my signature.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!