• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About servlet mapping rules

 
Luis Torres
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In mock question below I have:

Servlet name url-pattern
---------------------------------
ControlServlet | *.do
CertkillerServlet | /Certkiller/*

and I have these requests:

/Certkiller/
/Certkiller/index.jsp
/secure/command.do
/Certkiller/command.do

The question is for map the request to the appropriate servlet.

I read the spec about servlet mapping rules but isn't clear for me.

Thank for your help.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get this mock from ? Please quote your sources.
 
Luis Torres
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excuse me.
It's from JavaBeat.
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request - Maps to

/Certkiller/- CertKillerServlet
/Certkiller/index.jsp-CertKillerServlet
/secure/command.do-ControlServlet
/Certkiller/command.do-ControlServlet

Regards, Srinu
 
Deepak Vadgama
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet name url-pattern
---------------------------------
ControlServlet | *.do
CertkillerServlet | /Certkiller/*

/Certkiller/ CertkillerServlet
/Certkiller/index.jsp CertkillerServlet
/secure/command.do ControlServlet
/Certkiller/command.do CertkillerServlet

Rules for servlet mapping (in the order they are performed).
1. Exact occurrence is checked
2. Beginning part matches (There is a * in the end of URL pattern)
3. Extension match (* at the start and .extension (eg: .jsp,.do) at the end)

First match found by the container (considering above rules) wins.

Always remember Exact match -> Beginning match -> Extension match
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic