storing Objects in HtppSession


Web tier: servlets, JSP, Web frameworks: storing Objects in HtppSession

  1. storing Objects in HtppSession (1 messages)


      I would like to know how the objects are stored in HttpSession. is the reference only stored and only when the container must store the session in some persistant way all the object is serialized?
       When an object is serialized, is the whole object serialized, I mena, methods and attributes? If so, I suppose it´s better to store in session only object with attributes and let the objects whith the behaviour be created for each user request, am I rigth?


            Jose R.
  2. storing Objects in HtppSession[ Go to top ]

    Methods are never stored. Only the state of the objects = their field values, are stored.

    You should see an object as being a class definition + state.
    The methods & field names are part of the class definition, the field values are part of the state.

    When a session object is restored, the server remembers the class definition because it's part of your code. So it reconstructs such an object, and "fills" it with the persisted state.