You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Fabien Le Floc'h <mo...@altern.org> on 2001/07/19 07:57:39 UTC

web application initialization

Hi,

I would like to know if it is possible to have some code called at the web application initialization (something like the init() method of the first servlet called by the web app - which here is ActionServlet).

Should I just extend ActionServlet?


regards,

Fabien


Re: web application initialization

Posted by Calvin Yu <ca...@mindspring.com>.
Another thing you can do is use the ServiceManager extension that's
under the contrib 
directory in CVS.  I've just started to look at it myself.  Its seems to
be a fairly
new contributions, so documentation is pretty scarse.

Calvin



19 Jul 2001 21:05:32 -0700, Fabien Le Floc'h wrote:
> Thank you for the tip, this is definitely working and is not too ugly.
> 
> However I still find a little bit stupid we have to create a new Servlet just to use its init method. Or maybe not if your Log4j servlet allows you to modify the logging / the log4j properties remotely (but that is another project, and it is bad not to use struts for that).
> 
> I tried just to extend the ActionServlet and rewrite the init method (adding lines to it). After modifying the web.xml, it still did not work. Has anyone a clue why? Did anybody try to extend ActionServlet?
> 
> Regards,
> 
> Fabien
> 
> "Abraham Kang" <ab...@infogain.com> writes:
> 
> > Hi Fabien,
> > 
> >    I typically do this in a StartupServlet in my web.xml.
> > 
> >    Here is an example of how I initialize Log4j:
> > 
> > <web-app>
> > 
> >   <context-param>
> >     <param-name>weblogic.jsp.keepgenerated</param-name>
> >     <param-value>true</param-value>
> >   </context-param>
> > 
> >   <servlet>
> >     <servlet-name>log4j</servlet-name>
> > 
> > <servlet-class>com.infogain.DOG.logging.servlet.Log4jServlet</servlet-class>
> >     <init-param>
> >       <param-name>debug</param-name>
> >       <param-value>2</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>wlpi_log4j_conf</param-name>
> >       <param-value>/WEB-INF/wlpi_log4j_conf.properties</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>base_category</param-name>
> >       <param-value>com.infogain.DOG</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>base_priority</param-name>
> >       <param-value>info</param-value>
> >     </init-param>
> >   <load-on-startup>1</load-on-startup>
> >   </servlet>
> > 
> > ...
> > 
> >    The init() method of Log4jServlet handles stuff that needs to run before
> > Struts (struts's <load-on-startup> is 2).
> > 
> > --Abraham
> > 
> > > -----Original Message-----
> > > From: fabien@peanut.one0.com [mailto:fabien@peanut.one0.com]On Behalf Of
> > > Fabien Le Floc'h
> > > Sent: Wednesday, July 18, 2001 10:58 PM
> > > To: struts-user@jakarta.apache.org
> > > Subject: web application initialization
> > >
> > >
> > > Hi,
> > >
> > > I would like to know if it is possible to have some code called
> > > at the web application initialization (something like the init()
> > > method of the first servlet called by the web app - which here is
> > > ActionServlet).
> > >
> > > Should I just extend ActionServlet?
> > >
> > >
> > > regards,
> > >
> > > Fabien
> > >
> > >



Re: web application initialization

Posted by Fabien Le Floc'h <mo...@altern.org>.
Thank you for the tip, this is definitely working and is not too ugly.

However I still find a little bit stupid we have to create a new Servlet just to use its init method. Or maybe not if your Log4j servlet allows you to modify the logging / the log4j properties remotely (but that is another project, and it is bad not to use struts for that).

I tried just to extend the ActionServlet and rewrite the init method (adding lines to it). After modifying the web.xml, it still did not work. Has anyone a clue why? Did anybody try to extend ActionServlet?

Regards,

Fabien

"Abraham Kang" <ab...@infogain.com> writes:

> Hi Fabien,
> 
>    I typically do this in a StartupServlet in my web.xml.
> 
>    Here is an example of how I initialize Log4j:
> 
> <web-app>
> 
>   <context-param>
>     <param-name>weblogic.jsp.keepgenerated</param-name>
>     <param-value>true</param-value>
>   </context-param>
> 
>   <servlet>
>     <servlet-name>log4j</servlet-name>
> 
> <servlet-class>com.infogain.DOG.logging.servlet.Log4jServlet</servlet-class>
>     <init-param>
>       <param-name>debug</param-name>
>       <param-value>2</param-value>
>     </init-param>
>     <init-param>
>       <param-name>wlpi_log4j_conf</param-name>
>       <param-value>/WEB-INF/wlpi_log4j_conf.properties</param-value>
>     </init-param>
>     <init-param>
>       <param-name>base_category</param-name>
>       <param-value>com.infogain.DOG</param-value>
>     </init-param>
>     <init-param>
>       <param-name>base_priority</param-name>
>       <param-value>info</param-value>
>     </init-param>
>   <load-on-startup>1</load-on-startup>
>   </servlet>
> 
> ...
> 
>    The init() method of Log4jServlet handles stuff that needs to run before
> Struts (struts's <load-on-startup> is 2).
> 
> --Abraham
> 
> > -----Original Message-----
> > From: fabien@peanut.one0.com [mailto:fabien@peanut.one0.com]On Behalf Of
> > Fabien Le Floc'h
> > Sent: Wednesday, July 18, 2001 10:58 PM
> > To: struts-user@jakarta.apache.org
> > Subject: web application initialization
> >
> >
> > Hi,
> >
> > I would like to know if it is possible to have some code called
> > at the web application initialization (something like the init()
> > method of the first servlet called by the web app - which here is
> > ActionServlet).
> >
> > Should I just extend ActionServlet?
> >
> >
> > regards,
> >
> > Fabien
> >
> >


RE: web application initialization

Posted by Abraham Kang <ab...@infogain.com>.
Hi Fabien,

   I typically do this in a StartupServlet in my web.xml.

   Here is an example of how I initialize Log4j:

<web-app>

  <context-param>
    <param-name>weblogic.jsp.keepgenerated</param-name>
    <param-value>true</param-value>
  </context-param>

  <servlet>
    <servlet-name>log4j</servlet-name>

<servlet-class>com.infogain.DOG.logging.servlet.Log4jServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>wlpi_log4j_conf</param-name>
      <param-value>/WEB-INF/wlpi_log4j_conf.properties</param-value>
    </init-param>
    <init-param>
      <param-name>base_category</param-name>
      <param-value>com.infogain.DOG</param-value>
    </init-param>
    <init-param>
      <param-name>base_priority</param-name>
      <param-value>info</param-value>
    </init-param>
  <load-on-startup>1</load-on-startup>
  </servlet>

...

   The init() method of Log4jServlet handles stuff that needs to run before
Struts (struts's <load-on-startup> is 2).

--Abraham

> -----Original Message-----
> From: fabien@peanut.one0.com [mailto:fabien@peanut.one0.com]On Behalf Of
> Fabien Le Floc'h
> Sent: Wednesday, July 18, 2001 10:58 PM
> To: struts-user@jakarta.apache.org
> Subject: web application initialization
>
>
> Hi,
>
> I would like to know if it is possible to have some code called
> at the web application initialization (something like the init()
> method of the first servlet called by the web app - which here is
> ActionServlet).
>
> Should I just extend ActionServlet?
>
>
> regards,
>
> Fabien
>
>