Further to the mail that I sent earlier (below) I am getting some very odd
results from JRun 3.0 concerning servlet reloading.

In the example I do the following things:
- Create a servlet with a class variable (int)counter initialised to zero
- Simply over-ride init() - with no extra code in the method
- Over-ride doGet(), and increase counter and output its value in the method
- request the servlet multiple times - this works fine and the counter
increases
- I then change the output of doGet() and re-compile
At this point I expect the servlet to reload.  However I instaed get one of
two responses:
(a)  The servlet responds with the old counter value (i.e. the servlet has
not reloaded)
(b)  I get a nullpointer exception
The really odd thing here is that the response (a) or (b) dependes on how
quickly I request the servlet!!  If I rapidly refresh the page the response
is (a).  If I refresh more slowly the response is (b)!

This only seems to happen if I over-ride init().  If I take out the init()
method and follow the steps above then the mechanism works as expected (i.e.
the servlet reloads every time it is changed).

I am totally confused!  Has anyone else found this happening?

Any help would be greatly appretiated.

Regards,

Andy Phelps

-----Original Message-----
From: Andrew Phelps 
Sent: Wednesday, August 09, 2000 1:18 PM
To: '[EMAIL PROTECTED]'
Subject: servlet reloading.


Recently there was a discussion about the servlet reloading mechanism in
java web servers.

At the time I felt comfortable with the mechanism, but have recently
discovered a feature that I do not understand.

I have a basic servlet that ONLY overrides doGet().  When called the servlet
responds correctly. If I alter and recompile the servlet - and do not
restart the server - again the servlet responds correctly with the
alteration.

However, if I also override init() then the mechanism falls apart.  The
below example servlet will work correctly the first time it is compiled.
However, when an alteration is made (e.g. in doGet()) the server fails to
reload the servlet correctly.

Can anyone shed some light on what is happening internally?

Much appretiated,

Andy Phelps

== example follows ==
 
package test;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Output extends HttpServlet {

    int testInt = 0;

    public void init(ServletConfig config){
        // do nothing
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        out.println("Test output<BR>");// change this output,and load =
exception
        out.println("counter = " + testInt++);
     }
}
----------------------------------------------------------------------------
--
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe:
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe'
in the body.
------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

Reply via email to