• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet mapping question

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/*.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Dharmin.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic