How can this goal be accomplished?

You have a use in your web application that adds several session-scoped attributes. At the end of
the use case, one of these objects, the manage attribute, is removed and then it needs to decide
which of the other session-scoped attributes to remove.
How can this goal be accomplished?

You have a use in your web application that adds several session-scoped attributes. At the end of
the use case, one of these objects, the manage attribute, is removed and then it needs to decide
which of the other session-scoped attributes to remove.
How can this goal be accomplished?

A.
The object of the manager attribute should implement the HttpSessionBindingListener and it
should call the removeAttribute method on the appropriate session attributes.

B.
The object of the manager attribute should implement the HttpSessionListenar and it should call
the removeAttribute method on the appropriate session attributes.

C.
The object of the manager attribute should implement the HttpSessionBindingListener rind it
should call the deleteAttribute method on the appropriate session attributes.

D.
The object of the manager attribute should implement the HttpsessionListener and it should call
the deleteAttribute method on the appropriate session attributes.



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Allan Santos

Allan Santos

B.

Because is make sense and the others wont work.

HttpsessionListener has removeAttribute method.
HttpSessionBindingListener has valueUnbound method.

Tiparega

Tiparega

It’s A.
HttpSessionListener doesn’t have removeAtrribute or similar: http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSessionListener.html. Only works with creation and destruction of session.

HttpSessionBindingListener can be implemented *on the object* and in method valueUnbound it can call Session.removeAttribute() on needed attributes.
Attention! Question says “and *it should call the removeAttribute method* on the appropriate session attributes”, it doesn’t say anything about in which method it should call removeAttribute (that indeed is valueUnbound).