To add a servlet to a context that has not been declared either via annotation or via the descriptor, during context initialization time the following API can be used
(Choose three.)
A.
servletContext.addServlet(“myServletName”, “MyServlet”);
B.
servletContext.addServlet( (<Class extends
Servlet>)getClass().getClassLoader().getClassLoader().loaderClass(“MyServlet”));
C.
servletContext.addServlet(myServlet);
D.
servletContext.addServlet( (“myServletName”, <Class extends Servlet>)gerClass().getClassLoader().loaderClass(“myServlet”));
E.
servletContext.addServlet(“myServletName”, MyServlet);
Explanation:
addServlet
ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.Class<? extends Servlet> servletClass)
Adds the servlet with the given name and class type to this servlet context. The registered servlet may be further configured via the returned ServletRegistration
object.
Parameters:
servletName – the name of the servlet
servletClass – the class object from which the servlet will be instantiated
ADE
A,D,E