Re: Seems like my servlet isn't overloading the init() method..can someone plz help?

From: Tony Morris (not_at_telling.you)
Date: 03/03/05


Date: Thu, 03 Mar 2005 10:40:50 GMT


<carlos80@gmail.com> wrote in message
news:1109843689.138431.180320@l41g2000cwc.googlegroups.com...
> 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
>

The application server has almost certainly redirected the standard output
stream.
Also, you haven't overloaded the init method, you have overridden it - an
important distinction.
Search the application server documentation for where it redirects the
standard output stream - typically, some file in the logs.

-- 
Tony Morris
http://xdweb.net/~dibblego/


Relevant Pages

  • Re: Servlet startup completion
    ... Server has completely finished starting up and is forwarding requests ... The init method must complete successfully before the servlet can receive any requests. ... The web server could have been running for years when initis called. ... the initmethod for that servlet class might have been called before any number of times on other instances of the servlet. ...
    (comp.lang.java.programmer)
  • Re: Start a process as soon as Application Server starts
    ... > I have a process which is packaged in a JAR file and what it does is ... > collect some statistics on the server and email it as soon as the ... in your servlet's definition block: ... load your servlet when it starts and the servlet's init() method will ...
    (comp.lang.java.programmer)
  • Re: ServletOutputStream to Browser OK in NS, but not IE??
    ... >> I am replacing a Netscape Application Server appLogic with a servlet. ... >> the current browser session), but always pops up the file download box ... > client accepts and processes the messages via his user agent. ...
    (comp.lang.java.programmer)
  • Re: Ueberschreiben einer "verwendeten" Methode
    ... public abstract class TimeOutServlet extends HttpServlet { ... Server nacheinander abgefragt werden sollten. ... würde im Servlet nur den Queue anstossen, sofort eine Response zurückgeben und den Status/das Ergebnis per Polling im Browser anzeigen. ... Es könnte ja durchaus sein dass ein Browser ein Timeout auf <30 Sekunden gesetzt hat und die Abfrage von hunderten von Servern kann ja je nach Latenz der Server vermutlich auch länger dauern. ...
    (de.comp.lang.java)
  • Re: 2.6.17-rc4-mm1 nfsroot build err, looks related to klibc
    ... kinit: do_mounts ... arg 0: NFS-Mount' ... server 12aa8c0 hostname 192.168.42.1 ... Checking for init: /sbin/init ...
    (Linux-Kernel)