This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi , My query is why actionform implements serializable ? like any other class as it implements serializable ,it then can be serialized .But why we need that ? In most cases whatever persistance is required, we just take the form bean field values(i.e the properties) and persist them in the DB .Then why the formbean itself implements serializable ? Regards, Ayan
The J2EEServlet spec states that any object that is stored in an HTTPSession object should implement Serializable. The reason for this is that application servers in a distributed environment may need to serialize sessions for storage in a Database or transmission to a different JVM. Since One of the valid scopes for an ActionForm is session, it has to be serializable in order to meet this requirement.
ok .Thanks for the answer . I have query then,I can also store any Object ,say a simple Integer Object and in that I can store that using session.setAttribute(integerVariableName), but I think Integer Object does not implement serializable ? But still it can be stored in the session . then why it is stored then ? Regards, Ayan
Ayan, If you look at the JDK api doc on Integer object you will find that this object and all other wrapper objects does implements Serializable. Regarding why ActionsForms implements serializable:
- ActionForms can be stored in "session" scope. (refer struts-config.xml) and as Merrill said the session cannot be replicated to secondary server for failover if all the objects in session does not implements Serializable interface.
- However, if you application runs on just one server then you are free to objects which doesn't implement serializable interface in session. But this uncommon now. [ October 31, 2006: Message edited by: Purushothaman Thambu ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: why actionform is implements serializable ?