• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in servlet mapping

 
V Gala
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
47
Marks: 1 Given that a servlet is correctly declared with the tag

<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>com.examulator.HelloWorld</servlet-class>
</servlet>
Which of the following represent the correct syntax for mapping a servlet url to a servlet name

a)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>hello</url-pattern>
</servlet-mapping>

b)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>*.java</url-pattern>
</servlet-mapping>

c)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

d)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/com.examulator.HelloWorld</url-pattern>
</servlet-mapping>


Choose at least one answer.
a. a
b. b The servlet container doesn't care that the extension is .java it just sees it as a string and maps to it.
c. c This is a fairly standard maping and would match any given URL.
d. d I wouldn't recommend this type of mapping but it does work.

Answer is 3 and 4
why option 2 is wrong?

examulator.com
 
Ash More'
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i tried it when servlet-mapping as *.java. and it works without any problems. so option b seems to be right. anyways , the options have been badly phrased with abstract terms like fairly, recommend.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!