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