Which statement is true?

Given the java code snippet in contextInitialized method of a ServletContextListner:
ServletRegistration.Dynamic sr = (ServletRegistration.Dynamic)sc.addServlet
(“myServlet”, myServletClass);
sr.addMapping(“/abc”);
sr.setServletSecurityElement(servletSecurityElement);
sr.addMapping(“/def”);
Which statement is true?

Given the java code snippet in contextInitialized method of a ServletContextListner:
ServletRegistration.Dynamic sr = (ServletRegistration.Dynamic)sc.addServlet
(“myServlet”, myServletClass);
sr.addMapping(“/abc”);
sr.setServletSecurityElement(servletSecurityElement);
sr.addMapping(“/def”);
Which statement is true?

A.
“/abc” is mapped to “myservlet”. The servletSecurityElementy applies to both “/abc” and “/def”.

B.
Both “/abc” and “/def” are mapped to “myservlet”. The servletSecurityElementy applies to
“/abc”.

C.
Both “/abc” and “/def” are mapped to “myservlet”. The servletSecurityElementy applies to “/def”.

D.
Both “/abc” and “/def” are mapped to “myservlet”. The servletSecurityElementy applies to both
“/abc” and “/def”.

E.
Both “/abc” and “/def” are mapped to “myservlet”. The servletSecurityElementy applies to “/abc”,
but the behavior for “/def” is not specified.

Explanation:
Note:
* addMapping
public void addMapping(java.lang.String namespace,
java.lang.String name,
java.lang.Class clazz)

Defines a direct mapping from a namespace and name to a java class (and vice versa)



Leave a Reply 5

Your email address will not be published. Required fields are marked *


giuseppe farscadore

giuseppe farscadore

I would have answered D

giuseppe

giuseppe

so D correct