Serializable only means that it CAN be saved to disk, not that it will be.
You need to either deserialize/serialize the object in the Servlet's init()
and destroy() methods, or instruct the object to load/save it's state from
those methods.  It won't be done for you.
  (*Chris*)

----- Original Message -----
From: "Avinash Pedgaonker , SA, NIC" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 11, 2002 4:03 AM
Subject: [SERVLET-INTEREST] help required regarding serialisation of a bean


> i am writing a  bean for counter. I want to store the counter value when
the
> server is stopped and reload it when server restarts.I am using JRUN 4
> default web server for testing.
> my query is does JRUn automaticaly saves the object and reload it when we
> declare a class as implementing serializable?  if not the how to achieve
it?
>
> the script i have written is as below.
>
> import java.io.*;
> import java.util.*;
>
> public class dgftcounter implements Serializable {
>  private    int visitnumber ;
>
>  public int  getVisitnumber()
> {
>  visitnumber = visitnumber +1;
>  return visitnumber;
> }
>
> }
>
> i found that the visitnumber becomes  0 wheneever the server stops and
> restart. it mean the bean is not getting serialized.
> how can i write the method to serialize the bean. and how these methods
will
> get called by server when this bean is getting destroyed at the time of
> stopping of server.
>
> -avinash
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to