1:Which are true? (Choose all that apply.)
A. When a web application is preparing to shutdown, the order of listener notification is not guaranteed.
B. When listener-friendly events occur, listener invocation order is not predictable.
C. The container registers listeners based on declarations in the deployment descriptor.
D. Only the container can invalidate a session.
Answer is Given as C.Is that an errata.
2:Which statements about RequestDispatcher are true (where applicable, assume the RequestDispatcher was not obtained via a call to getNamedDispatcher())? (Choose all that apply.)
A. A RequestDispatcher can be used to forward a request to another
servlet.
B. The only method in the RequestDispatcher interface is forward().
C. Parameters specified in the query
string used to create a RequestDispatcher are not forwarded by the forward() method.
D. The servlet to which a request is forwarded may access the original query string by calling getQueryString() on the HttpServletRequest.
E. The servlet to which a request is forwarded may access the original query string by calling getAttribute(“javax.servlet.forward.query_string”) on the ServletRequest.
Answer was given as A,E.
Any error why is D not correct??
3:Given this code from an otherwise valid HttpServlet that has also been
registered as a ServletRequestAttributeListener:
10. public void doGet(HttpServletRequest req,
HttpServletResponse res)
11. throws IOException, ServletException {
12. req.setAttribute(“a”, “b”);
13. req.setAttribute(“a”, “c”);
14. req.removeAttribute(“a”);
15. }
16. public void attributeAdded(ServletRequestAttributeEvent ev) {
17. System.out.print(“ A:” + ev.getName() + “->” + ev.getValue());
18. }
19. public void attributeRemoved(ServletRequestAttributeEvent ev) {
20. System.out.print(“ M:” + ev.getName() + “->” + ev.getValue());
21. }
22. public void attributeReplaced(ServletRequestAttributeEvent ev) {
23. System.out.print(“ P:” + ev.getName() + “->” + ev.getValue());
24. }
What logging output is generated?
A. A:a->b P:a->b
B. A:a->b M:a->c
C. A:a->b P:a->b M:a->c
D. A:a->b P:a->b P:a->null
E. A:a->b M:a->b A:a->c M:a->c
F. A:a->b M:a->b A:a->c P:a->null
Can any one give me correct explanatuion for this??