Thanks.

I try this, but it is different from what I expected.

In my doGet() of my servlet, I have a Counter object in my session. 
When I reload the page in my browser, I see the value of the counter
increments. (say from "0" to "1" to "2").

Then I go to the Tomcat manager web page, and then "undeploy" the original
servlet, and "deploy" a newer version of the same servlet (context name is
the same). The value of the counter starts from "0" again when I reload the
page again.

The difference between the orginal servlet and the new servlet is the name
of the Method "inc()". I rename it to "newInc()" in the new servlet.

I am expecting the value of the counter will be "3" when I reload the
browser after I undeploy/deploy the servlet. Is this a correct assumption?

Here is the portion of the doGet() method in my servlet.

  public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
     HttpSession session = request.getSession(true);
        
        Counter sessionCounter = (Counter)
session.getAttribute("session_counter");
        
        if (sessionCounter == null) {
            sessionCounter = new Counter();
            session.setAttribute("session_counter", sessionCounter);
        }
        
       // rename inc() to newInc()
        sessionCounter.inc();
        out.println("session counter =");
        out.println(sessionCounter.getValue());
  }


-----Original Message-----
From: Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 05, 2004 7:44 AM
To: Tomcat Users List
Subject: RE: Hotswap servlet code in Tomcat 5?


Hi,

>If the objects in the session is serialized to the disk and then
>re-serialized when I re-deploy my servlet, what happens if the class in
my
>newer version of my servlet has
>- added/removed methods/attributes in the class
>- added/removed static variables in the class
>
>How will the hotswap work?

One has nothing to with the other, unless you're design is so bad that
it places a instance of your servlet class as a session attribute.

Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to