-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------
Hi All-
This is probably a stupid question, but I could not find an answer in the
FAQ.
The problem I'm having is that my servlet's init method is not being run
when it initializes for some reason. I've tried the simplest case, setting
global(class) integer to 5 in the init, and then printing it out in the
service method. The only way it ever prints out the correct value is if I
explicitly call the init() method at the beginning of the service routine.
Of course I can work around this with some logic in my service method that
will only call init() once, but this seems to be the ugly solution.
Any suggestions would be appreciated.
Example code is below...
class TestServlet extends HttpServlet {
int gvar = 0;
public void init() throws ServletException {
gvar = 5;
}
public void service ( ... ) {
out.println("gvar is " + gvar);
// this prints 0 and not 5... why?
}
}
--
Kendall Koning
Internet Operations Engineer, egl.net
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]