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 mapping question

 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is the following mapping valid? If so, what does it mean?
<servlet-mapping>
<servlet-name>reportServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Thanks,
Aruna.
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Another related question-
Is the following valid?
<servlet-mapping>
<servlet-name>BlueServlet</servlet-name>
<url-pattern>/blue/</url-pattern>
</servlet-mapping>
Thanks,
Aruna.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aruna
These are pretty basic questions for Servlet programming that a little bit of research on your part would easily resolve
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know, I know it sounds dumb but...
It looks like in the first case, a location of "/" gets mapped to just webapps/.
/blue/ in the second case gets mapped to webapps/blue since it is root relative but I don't understand what the second "/" will do. I would have understood it better if it had /blue/*.
 
Dharmin Desai
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear aruna,
1.
<servlet-mapping>
<servlet-name>reportServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

U r declaring a default servlet here. With every requests Container try to match Url pattern, if it found no match then it will call this servlet.
2.
<servlet-mapping>
<servlet-name>BlueServlet</servlet-name>
<url-pattern>/blue/</url-pattern>
</servlet-mapping>

It should call BlueServlet when path info is "/" and servlet path is "/Blue".
here second slash will restrict u to use path info not more then slash.
Whereas in case of
/blue/*
,
It is not restricting u on length/size of the path info.
Hope this helps,
Best Regards, Dharmin
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Dharmin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic