Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session doubts

 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

All are from HFSJ


When a session is moved from one JVM to another, attribute values that implement java.io.Serializable will be transferred to the the new JVM


The above is true for HttpSession objects in distributed env..

What my doubt is whether the attribute values which are not implementing the java.io.Serializable will not be transferred?

And Another doubt::

I want to know how HttpSessionBindingListener will be notified and also why the HttpSessionListener wii not be notified?

And also what are the listener will be notified for the below:
s.setAttribute("key","value");
[ December 31, 2006: Message edited by: Micheal John ]
 
VijayKumar Sivagnanam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how HttpSessionBindingListener will be notified and also why the HttpSessionListener wii not be notified?


HttpSessionBindingListener will be notified if the object which is set in the session implements HttpSessionBindingListener. The valueBound() method will be called when an object implementing this listener got added to the session.

HttpSessionListener is for HttpSession Life cycle events. sessionCreated() and sessionDestroyed() are the methods in it.


HttpSessionBindingListener and HttpSessionAttributeListener are the 2 listeners that get notified when you add some object to session.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the JavaBeans in the session are not serializable, the JVM will not know how to marshal the data across a network, and unmarshal the data on the other side. As a result, your applications will fail.

In a distributed environment, the data you put into your session must be serializable, otherwise you will face serious problems when you move to a clustered environment.

<opinion>
Making a bean serializable is not a dificult thing to do. Any programmer too lazy to conform to this interface when developing code deserves whatever runtime errors they run into at deployment time.
</opinion>

Cheers!

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic