Page: 6
Unit- 3: The Web Container Model
Q16. A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner. Which two can support this design goal? (Choose two.) A. Store the data in a local variable. B. Store the data in an instance variable. C. Store the data in the HttpSession object. D. Store the data in the ServletContext object. E. Store the data in the ServletRequest object. Answer: A, E Q17. Your web application uses a simple architecture in which servlets handle requests and then forward to a JSP using a request dispatcher. You need to pass information calculated in the servlet to the JSP for view generation. This information must NOT be accessible to any other servlet, JSP or session in the webapp. Which two techniques can you use to accomplish this goal?(Choose two.) A. Add attributes to the session object. B. Add attributes on the request object. C. Add parameters to the request object. D. Use the pageContext object to add request attributes. E. Add parameters to the JSP's URL when generating the request dispatcher. Answer: B Q18. Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web application deployment descriptor that contains: <context-param> <param-name>foo</param-name> <param-value>frodo</param-value> </context-param> Which two are true? (Choose two.) A. The foo initialization parameter CANNOT be set programmatically. B. Compilation fails because getInitParameter returns type Object. C. The foo initialization parameter is NOT a servlet initialization parameter. D. Compilation fails because ServletContext does NOT have a getInitParameter method. E. The foo parameter must be defined within the <servlet> element of the deployment descriptor. F. The foo initialization parameter can also be retrieved using getServletConfig().getInitParameter("foo"). Answer: A, C
Page: 6
1
2
3
4
5
6
7
8
9
10
|