You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Lehrian <da...@lehrian.com> on 2007/04/23 10:57:40 UTC

Issue w/ ActionServlet.init()...

I have an old application written using Struts 1.1 that has a subclass of ActionServlet which overrides the init() method to load data from some XML files.  It works fine w/ Struts 1.1.  I haven't touched it for years but now need to do some work on it.  My current Netbeans environment has Struts 1.2.9 and I figured I would just update it to the newer version but for the life of me I can't get the system to call the init() method.  I have the subclass listed as the action servlet in web.xml (snippet below) and I can break in the doGet and doPost methods so the servlet is definitely being used as the ActionServlet in the application.  Why isn't it calling the init() and/or init(ServletConfig config) methods?  

    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>TimeClockServlet2.TimeClockActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

Warm Regards,
Dave

Re: Issue w/ ActionServlet.init()...

Posted by David Lehrian <da...@lehrian.com>.
Hello Naill,
I put a bunch of System.out.print statements in the init method and learned 
it is actually being called.  I figured I could set a breakpoint in the 
init() method and that Netbeans would break at that point but this doesn't 
appear to be the case.  I find this behavior odd.  Thanks for the idea 
though of trying to make something show up on the console from inside the 
method.
Warm Regards,
Dave

----- Original Message ----- 
From: "Niall Pemberton" <ni...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, April 23, 2007 2:45 AM
Subject: Re: Issue w/ ActionServlet.init()...


> The init() and init(ServletConfig) methods are part of the servlet API
> - the container calls  init(ServletConfig) and that method then fires
> init() - so if they are not getting called then I don't think it has
> anything to do with Struts. Have you checked your logs for any errors?
>
> Niall
>
> On 4/23/07, David Lehrian <da...@lehrian.com> wrote:
>> I have an old application written using Struts 1.1 that has a subclass of 
>> ActionServlet which overrides the init() method to load data from some 
>> XML files.  It works fine w/ Struts 1.1.  I haven't touched it for years 
>> but now need to do some work on it.  My current Netbeans environment has 
>> Struts 1.2.9 and I figured I would just update it to the newer version 
>> but for the life of me I can't get the system to call the init() method. 
>> I have the subclass listed as the action servlet in web.xml (snippet 
>> below) and I can break in the doGet and doPost methods so the servlet is 
>> definitely being used as the ActionServlet in the application.  Why isn't 
>> it calling the init() and/or init(ServletConfig config) methods?
>>
>>     <servlet>
>>         <servlet-name>action</servlet-name>
>> 
>> <servlet-class>TimeClockServlet2.TimeClockActionServlet</servlet-class>
>>         <init-param>
>>             <param-name>config</param-name>
>>             <param-value>/WEB-INF/struts-config.xml</param-value>
>>         </init-param>
>>         <init-param>
>>             <param-name>debug</param-name>
>>             <param-value>2</param-value>
>>         </init-param>
>>         <init-param>
>>             <param-name>detail</param-name>
>>             <param-value>2</param-value>
>>         </init-param>
>>         <load-on-startup>2</load-on-startup>
>>     </servlet>
>>     <servlet-mapping>
>>         <servlet-name>action</servlet-name>
>>         <url-pattern>*.do</url-pattern>
>>     </servlet-mapping>
>>
>> Warm Regards,
>> Dave
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Issue w/ ActionServlet.init()...

Posted by Niall Pemberton <ni...@gmail.com>.
The init() and init(ServletConfig) methods are part of the servlet API
- the container calls  init(ServletConfig) and that method then fires
init() - so if they are not getting called then I don't think it has
anything to do with Struts. Have you checked your logs for any errors?

Niall

On 4/23/07, David Lehrian <da...@lehrian.com> wrote:
> I have an old application written using Struts 1.1 that has a subclass of ActionServlet which overrides the init() method to load data from some XML files.  It works fine w/ Struts 1.1.  I haven't touched it for years but now need to do some work on it.  My current Netbeans environment has Struts 1.2.9 and I figured I would just update it to the newer version but for the life of me I can't get the system to call the init() method.  I have the subclass listed as the action servlet in web.xml (snippet below) and I can break in the doGet and doPost methods so the servlet is definitely being used as the ActionServlet in the application.  Why isn't it calling the init() and/or init(ServletConfig config) methods?
>
>     <servlet>
>         <servlet-name>action</servlet-name>
>         <servlet-class>TimeClockServlet2.TimeClockActionServlet</servlet-class>
>         <init-param>
>             <param-name>config</param-name>
>             <param-value>/WEB-INF/struts-config.xml</param-value>
>         </init-param>
>         <init-param>
>             <param-name>debug</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <init-param>
>             <param-name>detail</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <load-on-startup>2</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>action</servlet-name>
>         <url-pattern>*.do</url-pattern>
>     </servlet-mapping>
>
> Warm Regards,
> Dave
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org