nerdexam
Oracle

1Z0-899 · Question #165

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.)

The correct answer is A. servletContext.addServlet("myServletName", "MyServlet"); D. servletContext.addServlet( ("myServletName", <Class extends E. servletContext.addServlet("myServletName", MyServlet). 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…

Servlets

Question

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.)

Options

  • AservletContext.addServlet("myServletName", "MyServlet");
  • BservletContext.addServlet( (<Class extends
  • CservletContext.addServlet(myServlet);
  • DservletContext.addServlet( ("myServletName", <Class extends
  • EservletContext.addServlet("myServletName", MyServlet);

How the community answered

(28 responses)
  • A
    79% (22)
  • B
    14% (4)
  • C
    7% (2)

Explanation

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. servletName - the name of the servlet servletClass - the class object from which the servlet will be instantiated

Topics

#dynamic servlet registration#ServletContext API#addServlet#programmatic configuration

Community Discussion

No community discussion yet for this question.

Full 1Z0-899 Practice