Page: 4
Unit- 4: Session Management
Q8. In your web application, you need to execute a block of code whenever the session object is first created. Which design will accomplish this goal? A. Create an HttpSessionListener class and implement the sessionInitialized method with that block of code. B. Create an HttpSessionActivationListener class and implement the sessionCreated method with that block of code. C. Create a Filter class, call the getSession(false) method, and if the result was null, then execute that block of code. D. Create an HttpSessionListener class and implement the sessionCreated method with that block of code. E. Create a Filter class, call the getSession(true) method, and if the result was NOT null, then execute that block of code. Answer: D Q9. Which interface must a class implement so that instances of the class are notified after any object is added to a session? A. javax.servlet.http.HttpSessionListener B. javax.servlet.http.HttpSessionValueListener C. javax.servlet.http.HttpSessionBindingListener D. javax.servlet.http.HttpSessionAttributeListener Answer: D Q10. Which method must be used to encode a URL passed as an argument to HttpServletResponse.sendRedirect when using URL rewriting for session tracking? A. ServletResponse.encodeURL B. HttpServletResponse.encodeURL C. ServletResponse.encodeRedirectURL D. HttpServletResponse.encodeRedirectURL Answer: D
Page: 4
1
2
3
4
5
6
7
8
9
10
|