Re: Seems like my servlet isn't overloading the init() method..can someone plz help?
From: Nigel Wade (nmw_at_ion.le.ac.uk)
Date: 03/03/05
- Next message: Ramnish Kalsi: "applet & image params"
- Previous message: Antti S. Brax: "Re: getBytesUTF8Encoded"
- In reply to: carlos80_at_gmail.com: "Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Next in thread: John C. Bollinger: "Re: Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Reply: John C. Bollinger: "Re: Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 03 Mar 2005 12:02:37 +0000
carlos80@gmail.com wrote:
> 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
To get init() to be invoked you either need to set <load-on-startup> to 1 in
web.xml, or have a client access the servlet. Has this been done? Where
are you looking for the output?
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
- Next message: Ramnish Kalsi: "applet & image params"
- Previous message: Antti S. Brax: "Re: getBytesUTF8Encoded"
- In reply to: carlos80_at_gmail.com: "Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Next in thread: John C. Bollinger: "Re: Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Reply: John C. Bollinger: "Re: Seems like my servlet isn't overloading the init() method..can someone plz help?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|