Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Questions on HttpSession

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome 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.

 
Saloon Keeper
Posts: 6454
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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
Eclipse IDE Chrome 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
Saloon Keeper
Posts: 6454
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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
Eclipse IDE Chrome 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
Saloon Keeper
Posts: 6454
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic