• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions on HttpSession

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

correct answer-D
I think the most appropriate answer is C.
HttpSessionBindingListener helps the class to know when its objects are added or removed from session.
As,there is no mention of object replaced in the question.


----------------------------------------------------------------------------------------------
Q6. What is the purpose of session management?
A. To manage the user's login and logout activities.
B. To store information on the client-side between HTTP requests.
C. To store information on the server-side between HTTP requests.

Correct answer is C

As per my understanding the correct answer should be A,B.
The cookies are stored on client side and Server retrieves it after appending it to the request.

 
Tim Moores
Bartender
Posts: 3127
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As to #1, note that it says any object. It it had said "objects of that particular class" then HttpSessionBindingListener would have been a better answer.

As to #2, there isn't necessarily a relationship between session and cookies (sessions work just fine without cookies through URL rewriting). The storage takes place on the server, not the client.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim
But I am still not convinced with the explanation that you have given for the second question.
 
Tim Moores
Bartender
Posts: 3127
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How so? With respect to answer A, sessions don't have to be about login/logout at all; they're about a user visiting a web site - no login need be involved for that. Why do you think it might be about client-side storage? The cookie (if one is even involved) is not what "storage" means in this context.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The cookie (if one is even involved) is not what "storage" means in this context.


What does Storage means Here ?

I thought It must be cookie as this is one that is created on server side and attached to client requests
 
Tim Moores
Bartender
Posts: 3127
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Storage" refers to what is stored in the session.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic