This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionForm is serialized

 
wrushasen dakhane
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

ActionForm is serialized. I want to know what is the perpose of making ActionForm serialized because normally we do not persist the ActionForm data.

Wrushasen
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The J2EE spcification states that any object that is placed in session scope (or in other words may be set as an attribute of the HTTPSession object) must implement serializable. Since one of the possible scopes for an ActionForm is session, this mandate applies to an ActionForm.

The reason for this is that application servers have the option of persisting session data to disk, particularly if they need to do so to allow for more concurrent sessions. They may swap the session in and out of memory as needed.
 
wrushasen dakhane
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

"The reason for this is that application servers have the option of persisting session data to disk, particularly if they need to do so to allow for more concurrent sessions. They may swap the session in and out of memory as needed."

I didn't understand your above statement.

wrushu
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps the best way to explain it is with an example. Suppose there are currently 2000 concurrent users on your app server, all of whom have session objects in memory. The app server realizes that there isn't going to be enough memory if any more sessions are added. It might then take the 10 sessions that have been inactive for the longest time, serialize the objects, write them to disk in a temporary file, and remove them from memory. If the user for one of those sessions submits a new request, the app server recognizes that this is one of the serialized sessions, de-serializes it, and places it back in memory where it can be accessed.

If the session has a reference to an object that is not serializable, the app server obviously won't be able to serialize the session and will throw an exception when it tries to do so.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic