Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet mapping  RSS feed

 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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>
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Arun Chidambaram
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!