• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SERIALIZABLE INTERFACE

 
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do we need to implement Serializable interface on Java Beans (getter/setter methods)?
In my application, I am implementing Serializable interface for all java beans. I know that, I am doing it for the persistence. But I neither use ObjectInput/OutputStreams to read and write to file system, hard disk and nor handle any other kind of persistence when system crashes/or when system down.
It is advisable to store all data in one bean and in turn it should store in session object, hence I will have only one session object through out my application .Why is it advisable that object to be implemented by Serializable interface. How data is going to be persisted? I am not writing and persistence logic in my application.
Please answer my question�.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U have made a bean class and is used in servlet and jsp page. now a user access that servlet/jsp page and your bean variables have changed to new value.and u are keeping it in session, so that a later time u can retrieve the values from session. but tell me how u are going to store it in session. I mean when u are saying that "storing" in session, u mean that your object should be persistant. isn't it... The web container treats it in that way.
got it......
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you did not answer my question.I know that storing object in session will be persisted through out the user session.
But my question is given below..
Why do we need to implement Serializable interface on Java Beans (getter/setter methods)?
 
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi thomas,
the web server needs the bean to be serializable
as for it to maintain the session information the beans may be written to a flat file on the server and read again when required.
even if u are not doin any writing\reading to the flat file on ur own the server needs it to handle persistance though this may vary from server to server.
I hope that clears ur doubt.
Devesh H Rao
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if the object is not implemented by serializable, I am able to store it in session and retrieve back when I required the data from it. I think the session management does not demand for making that object serializable.
I would like to know why does web server use serializable interface when java object being used for getting and setting data from FORM (getter/setter methods)?
Why is it advisable an object to be implemented by serializable(web application)?
Whether to support session management capability of web server or to support crisis management, I mean in case of system crash/server down etc..
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I understand it, it is up to the servlet container designer to decide whether or not to serialize sessions out to disk or database when it starts to run out of memory - the alternative being to just discard the session before the normal timeout.
Your session with a non-serializable object may work just fine with a given server and usage load but fail when the load gets higher.
Serializing out to disk or database is a simple way to make your application more able to survive system crashes, etc. - it really is pretty fast. Also, of course, serializing objects is basic to functioning in the J2EE environment.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic