This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes implementing serializeble interface in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "implementing serializeble interface in bean" Watch "implementing serializeble interface in bean" New topic
Author

implementing serializeble interface in bean

Gevarghese
Greenhorn

Joined: Sep 25, 2006
Posts: 6
Is it mandatory to implement sirializable or Externalizable interface for creation of bean ? please explain to me how can you relate bean with these interfaces
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

No, it's not mandatory. If you're learning servlets/jsp now, you won't need to implement the interface.
You will have to when you're bean is put in a session in a distrubuted environment, if you want it to be migrated properly.


[My Blog]
All roads lead to JavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you plan on storing these beans in session, it's a good idea to make them serializable. Some containers (Tomcat, that I know of) will serialize all sessions to disk when the app or container is shut down for a re-start.
It then reads them back when it starts up.

If any object bound to session, directly or indirectly, doesn't implement serializable, this whole operation fails.

Also, as Ulf mentioned, in a clustered environment, Tomcat uses serialization for session replication.

I'm sure most containers have similar functionality.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

"gevarghese kv",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Is it not one of the primary requirements of being a bean that it is Serializable?

The serializable interface is more of a marker than anything else. It just says "this class can be serialized". Most of the time the default implementation is just fine - so just make your bean "implement java.io.Serializable" and you're pretty much done.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: implementing serializeble interface in bean
 
Similar Threads
Mock Question
how can we find weather it is a statful session or stateless
Problem with Stateless EJB in JBOSS 4.0.4
Need of SessionSynchronization interface
stateful bean with weblogic8.1