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…
Question
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)- A79% (22)
- B14% (4)
- C7% (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
Community Discussion
No community discussion yet for this question.