File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "implementing serializeble interface in bean" Watch "implementing serializeble interface in bean" New topic

implementing serializeble interface in bean


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é

Joined: Nov 24, 2005
Posts: 14688

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

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

Joined: Jan 10, 2002
Posts: 63852

"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.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
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" and you're pretty much done.
I agree. Here's the link:
subject: implementing serializeble interface in bean
It's not a secret anymore!