Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet-name

 
Vin Ram
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello folks,

Am a bit confused. If <servlet-name> appears under <servlet>, it is like a DD internal servlet name and if it appears inside <filter-mapping>, it is treated like <url-pattern>. Am I correct?

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each servlet-name is unique, and used to identify a servlet.
If you decide to put a filter to a particular servlet,
you can specify its name in the <servlet-name> of <filter-mapping>.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to the specs. There is no other better substitute.

Servlet 2.4 specs (pdf), SRV.6.2.3 Page 53.
You can download it here.
 
Vin Ram
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did look up the spec and am still confused. Please see below ...

<servlet>
<servlet-name>MyServlet<servlet-name> --> (1)
<servlet-class>com.testservlet<servlet-class>
<servlet>
<servlet-mapping>
<servlet-name>MyServlet<servlet-name> --> (1)
<url-pattern>/foo/bar<url-pattern>
<servlet-mapping>

<filter-mapping>
<filter-name>MyFilter</filter-name>
<servlet-name>MyServlet</servlet-name> --> (2)
</filter-mapping>


Is 2 related to 1 in anyway? Or is (2) treated like a url pattern for the filter? Thanks
 
M Jairam
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your original question as to <servlet-name> is treated as <url-pattern> if under <filter-mapping>, the answer is "you are correct". Also, note that <servlet-mapping> is independent of <filter-mapping>. <servlet-name> appearing under <filter-mapping> is like an exact match.
However, note one difference between <url-pattern> and <servlet-name> under <filter-mapping>, the ordering of filters - which is very important - are different between the two. The container will first take all filters matching the url, first against all of the <url-pattern>, in the order it appears in the DD, and then will match against all of the <servlet-name>, in the order it appears in the DD.
hth.
[ December 14, 2005: Message edited by: M Jairam ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic