Page: 9
Unit- 3: The Web Container Model
Q25.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 Q26. 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, E Q 27. Which three are true about servlet filters? (Choose three.) A. A filter must implement the destroy method. B. A filter must implement the doFilter method. C. A servlet may have multiple filters associated with it. D. A servlet that is to have a filter applied to it must implement the javax.servlet. FilterChain interface. E. A filter that is part of a filter chain passes control to the next filter in the chain by invoking the FilterChain.forward method. F. For each <filter> element in the web application deployment descriptor, multiple instances of a filter may be created by the web container. Answer: A, B, C
Page: 9
1
2
3
4
5
6
7
8
9
10
|