At 02:31 PM 5/8/00 -0500, you wrote:

I'am not talking about classes that i lost when i
reload my servlets...

I lost objects that i store in memory, that manage
the state of users between requests...
i just found a document in

http://www.magiccookie.com/computers/apache-jserv/#Class Path and Class Reloading

that talk about this situation...they suggest that i save
my objects in a permanent store before the reload of the
servlets, how i save objects in a permanent store ???

have somebody another solution ???

thanks for any help....

Possibly I'm confused about your question.  I made a test servlet that writes init/destroy messages to the log,
and with the following doGet() method:

         protected void doGet( javax.servlet.http.HttpServletRequest  req,
                               javax.servlet.http.HttpServletResponse resp )
                        throws javax.servlet.ServletException, java.io.IOException
         {
        
                 HttpSession            session = req.getSession( true );
                 java.util.Date         crDate;
                
                
                 resp.setContentType( "text/html" );
                 PrintWriter            pw = resp.getWriter();
                
                 pw.println( "<html><head></head><body>" );
                
                 pw.println( "<h2>BasicServlet</h2><br>" );
                
                 if ( session.isNew() )
                 {
                        crDate = new java.util.Date();
                        pw.println( "New session<br>" );
                        session.putValue( "thedate", crDate );
                        pw.println( "Cr time (msecs): " + crDate.getTime() + "<br>" );
                 }
                 else
                 {
                        pw.println( "OLD session<br>" );
                        crDate = (java.util.Date)session.getValue( "thedate" );
                        if ( crDate == null )
                        {
                                pw.println( "WOW!! Lost session object<br>" );
                                crDate = new java.util.Date();
                                session.putValue( "thedate", crDate );
                        }
                        else
                                pw.println( "Cr time (msecs): " + crDate.getTime() + "<br>" );
                 }
                 pw.println( "</body></html>" );
         }

As you can see, it stores an object in a browser session.  The first time you access this servlet from a browser, you will see something
like:

        BasicServlet

        New session
        Cr time (msecs): 957829663227

then, when you hit refresh, you'll see:

        BasicServlet

        OLD session
        Cr time (msecs): 957829663227

Next, if you recompile the class and copy the new version to the repository directory, and then refresh your browser once again, you will see the OLD session message and the original time, *even though* you can see in the log that the servlet instance has been destroyed and re-loaded.

So, like I said, I don't see the problem -- in JServ session data *clearly* outlives the servlet instance that created it. I believe the magic-cookie article is referring to state data that you store via instance variables in the servlet itself.  Any such data would indeed be lost when the servlet is reloaded.

Good luck.

Reply via email to