C
carlos80
Hi,
I've been struggling with this problem all night, and I feel like I'm
just missing something.
I'm basically trying to run some code in the init() method in my
servlet. However the method doesn't seem to be getting called. I know
that the init() method is only called once the first time the servlet
gets called, and that is exactly why I'm stuck with this problem.
Here is a sample of my code
public class MyServletA extends HttpServlet {
// Page names
private static int a;
public void init() throws ServletException {
super.init();
a = 4;
System.out.println("init");
}
public void doPost(...) {
System.out.println(a);
}
}
When I start the server and load the jsp that calls MyServletA I never
get the "init" to print out, and when doPost gets called a = 0 and not
4.
Can someone please shed some light in this? Thanks
I've been struggling with this problem all night, and I feel like I'm
just missing something.
I'm basically trying to run some code in the init() method in my
servlet. However the method doesn't seem to be getting called. I know
that the init() method is only called once the first time the servlet
gets called, and that is exactly why I'm stuck with this problem.
Here is a sample of my code
public class MyServletA extends HttpServlet {
// Page names
private static int a;
public void init() throws ServletException {
super.init();
a = 4;
System.out.println("init");
}
public void doPost(...) {
System.out.println(a);
}
}
When I start the server and load the jsp that calls MyServletA I never
get the "init" to print out, and when doPost gets called a = 0 and not
4.
Can someone please shed some light in this? Thanks