• 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

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following XML codes correctly specify a URL to servlet mapping in the deployment descriptor of a web application?

1.
<servlet-mapping>
<servlet-name>catalog</servlet-name>
<url-pattern>/catalog/*</url-pattern>
</servlet-mapping>


2.
<servlet-mapping>
<servlet-name>com.abcinc.CatalogServlet.class</servlet-name>
<url-pattern>/catalog/*</url-pattern>
</servlet-mapping>
 
author & internet detective
Posts: 41905
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Geetu,
It depends on what you set as the <servlet-name> in the <servlet> tag. It is more likely that you would have used a name as opposed to the fully qualified class name.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Geetu,
Your servlet mapping info is not complete,

Servlet mapping has two parts - <servlet> & <servlet-mapping>

first one defines servlet name & class file
second one defines URL pattern & name of the servlet(should match with first one)

see example

<servlet>
<servlet-name>SampleServlet</servlet-name>
<servlet-class>com.example.SimpleServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>SampleServlet</servlet-name>
<url-pattern>/test/sample.do</url-pattern>
</servlet-mapping>

SimpleServlet can be accessed with help of below url

<a href="http://www.abcd.com/FirstApp/<b rel="nofollow">test/sample.do</b>" target="_blank">http://www.abcd.com/FirstApp/test/sample.do

-----------------------
Arun.C,
SCJP1.4,SCWCD1.4
 
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"ArunChidam",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Arun C"

Your name still does not follow the javaranch naming guidelines. Please update it as previously described. This is your second warning.

-Scott
 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree to both of you Jeanne and Arun.

I was actually going through some dummy questions and this was one of them. So i posted this. The note that was there was the fully qualified names was wrong. but i have seen it work.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic