Go back to 1Z0-858 - Java Enterprise Edition 5 Web Component Developer Certified Professional Exam

Question :-

Your web site has many user-customizable features, for example font and color preferences on web pages. Your IT department has already built a subsystem for user preferences using Java SE's lang.util.prefs package APIs and you have been ordered to reuse this subsystem in your web application. You need to create an event listener that stores the user's Preference object when an HTTP session is created. Also, note that user identification information is stored in an HTTP cookie. Which partial listener class can accomplish this goal?
public class UserPrefLoader implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { MyPrefsFactory myFactory = (MyPrefsFactory) se.getServletContext().getAttribute("myPrefsFactory"); User user = getUserFromCookie(se); myFactory.setThreadLocalUser(user); Preferences userPrefs = myFactory.userRoot(); se.getSession().setAttribute("prefs", userPrefs); } // more code here }
public class UserPrefLoader implements SessionListener { public void sessionCreated(SessionEvent se) { MyPrefsFactory myFactory = (MyPrefsFactory) se.getContext().getAttribute("myPrefsFactory"); User user = getUserFromCookie(se); myFactory.setThreadLocalUser(user); Preferences userPrefs = myFactory.userRoot(); se.getSession().addAttribute("prefs", userPrefs); } // more code here }
public class UserPrefLoader implements HttpSessionListener { public void sessionInitialized(HttpSessionEvent se) { MyPrefsFactory myFactory = (MyPrefsFactory) se.getServletContext().getAttribute("myPrefsFactory"); User user = getUserFromCookie(se); myFactory.setThreadLocalUser(user); Preferences userPrefs = myFactory.userRoot(); se.getHttpSession().setAttribute("prefs", userPrefs); } // more code here }
public class UserPrefLoader implements SessionListener { public void sessionInitialized(SessionEvent se) { MyPrefsFactory myFactory = (MyPrefsFactory) se.getServletContext().getAttribute("myPrefsFactory"); User user = getUserFromCookie(se); myFactory.setThreadLocalUser(user); Preferences userPrefs = myFactory.userRoot(); se.getSession().addAttribute("prefs", userPrefs); } // more code here }

Want to practice for 1Z0-858 - Java Enterprise Edition 5 Web Component Developer Certified Professional Exam ? Click here.