Your web application requires the adding and deleting of many session attributes during a complex usecase. A bug report has come in that indicates that an important session attribute is being deleted too soonand a NullPointerException is being thrown several interactions after the fact. You have decided to create asession event listener that will log when attributes are being deleted so you can track down when theattribute is erroneously being deleted.
Which listener class will accomplish this debugging goal?()
A.Create an HttpSessionAttributeListener class and implement the attributeDeleted method and log the attribute name using the getName method on the event object.
B.Create an HttpSessionAttributeListener class and implement the attributeRemoved method and log the attribute name using the getName method on the event object.
C.Create an SessionAttributeListener class and implement the attributeRemoved method and log the attribute name using the getAttributeName method on the event object.
D.Create an SessionAttributeListener class and implement the attributeDeleted method and log the attribute name using the getAttributeName method on the event object.
您可能感興趣的試卷
你可能感興趣的試題
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?()
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));
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.
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?()
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)
Click the Exhibit button.
The resource requested by the RequestDispatcher is available and implemented by the Destination Servlet.
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.
You want to create a filter for your web application and your filter will implement javax.servlet.Filter.
Which two statements are true?()
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 doFiltermethod.
D.The method that your filter invokes on the object it received that implements javax.servlet.FilterChaincan invoke either another filter or a servlet.
E.Your filter class must implement a doFilter method that takes, among other things, anHTTPServletRequest object and an HTTPServletResponse object.
最新試題
You are building a dating web site. The client’s date of birth is collected along with lots of other information.The Person class has a derived method, getAge():int, which returns the person’s age calculated from thedate of birth and today’s date. In one of your JSPs you need to print a special message to clients within theage group of 25 through 35.Which two EL code snippets will return true for this condition? ()
Click the ’Select and Place’ button.Place the events in the order they occur.
Click the ’Select and Place’ button.Place the events in the order they occur.
Your company has a corporate policy that prohibits storing a customer’s credit card number in anycorporate database. However, users have complained that they do NOT want to re- enter their credit cardnumber for each transaction. Your management has decided to use client-side cookies to record the user’scredit card number for 120 days. Furthermore, they also want to protect this information during transit fromthe web browser to the web container; so the cookie must only be transmitted over HTTPS.Which codesnippet creates the "creditCard" cookie and adds it to the out going response to be stored on the user’s webbrowser?()
Click the Exhibit button.The attribute "name" has a value of "Foo,"What is the result if this tag handler’s tag is invoked?()
Click the 'Select and Place' button.Place the events in the order they occur.
Which is a benefit of precompiling a JSP page?()
Click the 'Select and Place' button.Place the events in the order they occur.
Click the ’Select and Place’ button.Place the events in the order they occur.
Click the ’Select and Place’ button.Place the events in the order they occur.