Page: 3
Unit- 3: The Web Container Model
Q7.Click the Exhibit button. The resource requested by the RequestDispatcher is available and implemented by the DestinationServlet. What is the result? 
A. An exception is thrown at runtime by SourceServlet. B. An exception is thrown at runtime by DestinationServlet. C. Only "hello from dest" appears in the response output stream. D. Both "hello from source" and "hello from dest" appear in the response output stream. Answer: A Q8.Given the definition of MyServlet: 11. public class MyServlet extends HttpServlet { 12. public void service(HttpServletRequest request, 13. HttpServletResponse response) 14. throws ServletException, IOException { 15. HttpSession session = request.getSession(); 16 session.setAttribute("myAttribute","myAttributeValue"); 17. session.invalidate(); 18. response.getWriter().println("value=" + 19. session.getAttribute("myAttribute")); 20. } 21. } What is the result when a request is sent to MyServlet? A. An IllegalStateException is thrown at runtime. B. An InvalidSessionException is thrown at runtime. C. The string "value=null" appears in the response stream. D. The string "value=myAttributeValue" appears in the response stream. Answer: A Q9.You need to store a Java long primitive attribute, called customerOID, into the session scope. Which two code snippets allow you to insert this value into the session? (Choose two.) A. long customerOID = 47L; session.setAttribute("customerOID", new Long(customerOID)); B. long customerOID = 47L; session.setLongAttribute("customerOID", new Long(customerOID)); C. long customerOID = 47L; session.setAttribute("customerOID", customerOID); D. long customerOID = 47L; session.setNumericAttribute("customerOID", new Long(customerOID)); E. long customerOID = 47L; session.setLongAttribute("customerOID", customerOID); F. long customerOID = 47L; session.setNumericAttribute("customerOID", customerOID); Answer: A, C
Page: 3
1
2
3
4
5
6
7
8
9
10
|