Well, I suppose you do nothing more than what the specs states in most cases. Here's a 
snippet of such a init webapp definition with two servlets ie. Struts controller and 
your init servlet.
Your initServlet can cache some app scope parameters or whatever else.
Enjoy.



-----Original Message-----
From: Yan Zhu [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 6:55 PM
To: Emmanuel Bridonneau
Subject: Re: first action



great, thanks. how do you declare it in the web.xml?

Emmanuel Bridonneau wrote:

> You usually want to do this whilst initializing you app. In this case, simple and 
>pretty much standard would be to write a servlet (generic if you don't want to be 
>tied to http) as part of your web-app. All you do is implement its init() method and 
>declare it in your web.xml. Only once init is done for all your servlets, can the 
>users hit your pages.
> Emmanuel
>
> -----Original Message-----
> From: Damm, Gary [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 6:35 PM
> To: Struts Users Mailing List; [EMAIL PROTECTED]
> Subject: RE: first action
>
> Sounds more like a PlugIn.  Here are the API docs:
> http://jakarta.apache.org/struts/api/org/apache/struts/action/PlugIn.htm
> l
>
> You just implement this interface, configure it in your config.xml file
> and you're up and running.
>
> Gary
>
> -----Original Message-----
> From: Yan Zhu [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 6:26 PM
> To: Struts Users Mailing List
> Subject: first action
>
> hey guys,
>
>     what is the best way to implement a startup action that always will
> be executed first before any jsp is hit?
>
>     thanks
>
> yan
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

<web-app>
    <servlet>
      <servlet-name>controller</servlet-name>
		. . . <!-- usual struts definition -->
    </servlet>

    <servlet>
      <servlet-name>initWebApp</servlet-name>
      <description>
        This servlet produces GIF images that are dynamically generated
        graphs, based on the input parameters included on the request.
        It is generally mapped to a specific request URI like "/graph".
      </description>
      <servlet-class>com.mycompany.mypackage.InitServlet</servlet-class>
      <init-param>
        <param-name>listOrders</param-name>
        <param-value>com.mycompany.myactions.ListOrdersAction</param-value>
      </init-param>
      <!-- Load this servlet at server startup time -->
      <load-on-startup>5</load-on-startup>
    </servlet>

    <servlet-mapping>
      <servlet-name>controller</servlet-name>
      <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
      <servlet-name>initWebApp</servlet-name>
      <url-pattern>/init</url-pattern>
    </servlet-mapping>
</web-app>


and then in your initWebApp,
     //Servlet initialization parameters can be retrieved in a servlet or JSP page by calling:
     String value =
          getServletConfig().getInitParameter("saveCustomer");
    ServletContext myWebContext= getServletConfig().getServletContext();
    myWebContext.getAttribute(AttributeKeys.WEB_CACHE) ; get/setAttribute

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to