Page: 2
Unit- 3: The Web Container Model
Q4.You want to create a filter for your web application and your filter will implement javax.servlet.Filter. Which two statements are true? (Choose two.) A. Your filter class must implement an init method and a destroy method. B. Your filter class must also implement javax.servlet.FilterChain. C. When your filter chains to the next filter, it should pass the same arguments it received in its doFilter method. D. The method that your filter invokes on the object it received that implements javax.servlet.FilterChain can invoke either another filter or a servlet. E. Your filter class must implement a doFilter method that takes, among other things, an HTTPServletRequest object and an HTTPServletResponse object. Answer: A, D Q5.Which three are true about the HttpServletRequestWrapper class? (Choose three.) A. The HttpServletRequestWrapper is an example of the Decorator pattern. B. The HttpServletRequestWrapper can be used to extend the functionality of a servlet request. C. A subclass of HttpServletRequestWrapper CANNOT modify the behavior of the getReader method. D. An HttpServletRequestWrapper may be used only by a class implementing the javax.servlet.Filter interface. E. An HttpServletRequestWrapper CANNOT be used on the request passed to the RequestDispatcher.include method. F. An HttpServletRequestWrapper may modify the header of a request within an object implementing the javax.servlet.Filter interface. Answer: A, B, F Q6.A developer wants to make a name attribute available to all servlets associated with a particular user, across multiple requests from that user, from the same browser instance. Which two provide this capability from within a tag handler? (Choose two.) A. pageContext.setAttribute("name", theValue); B. pageContext.setAttribute("name", getSession()); C. pageContext.getRequest().setAttribute("name", theValue); D. pageContext.getSession().setAttribute("name", theValue); E. pageContext.setAttribute("name", theValue, PageContext.PAGE_SCOPE); F. pageContext.setAttribute("name", theValue, PageContext.SESSION_SCOPE); Answer: D, F
Page: 2
1
2
3
4
5
6
7
8
9
10
|