File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Worker Beans and Serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Worker Beans and Serializable" Watch "Worker Beans and Serializable" New topic

Worker Beans and Serializable

Eric Howell
Ranch Hand

Joined: Nov 26, 2000
Posts: 63
I think it is common practice to implement JavaBeans (eg worker beans etc) with the serializable interface. Some books etc sometimes give examples that don't.
Also the same applies to providing a no args constructor.
When just using JavaBeans in say a MVC design pattern what is the common or correct practice.
What is the advantage and what is the correct practice. This is a source of confusion to me.
I wonder is someone could put in their two cents or pence( any currency is OK )
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12938
One possible reason for making any helper class serializable is that if you store an instance in a session, the servlet engine may be able to store the session out to disk to save memory.
[ March 06, 2002: Message edited by: William Brogden ]
Eric Howell
Ranch Hand

Joined: Nov 26, 2000
Posts: 63
Thanks for that Bill.
I get a little confused with definitions.
I wonder, how could we best define a 'worker bean'.
Would it be a bean used by the JSP to do a job eg displaying some info from the db or some connection etc. How would it differ in definition from another bean.
Also, could a bean called from a servlet (in an MVC type system) be defined as a worker bean.
Thanks in advance
It is sorta covered in the JavaRanch Style Guide.
subject: Worker Beans and Serializable