struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hubert Rabago <jakartau...@yahoo.com>
Subject Re: non-default init-params and default ActionServlet
Date Sat, 21 Feb 2004 01:19:41 GMT
I might be missing something here, but why not get it inside the servlet
context initialized handler method?

    public void contextInitialized(ServletContextEvent event) {
        System.out.println("[contextInitialized] inside
contextInitialized()");
        System.out.println(" +-> context=" + event.getServletContext());
        ServletContext context = event.getServletContext();
        Enumeration enumeration = context.getInitParameterNames();
        while (enumeration.hasMoreElements()) {
            String name = (String) enumeration.nextElement();
            String value = context.getInitParameter(name);
            System.out.println("init param: [" + name + "=" + value + "]");
        }
    }

    public void contextDestroyed(ServletContextEvent event) {
        System.out.println("[contextDestroyed] inside contextDestroyed()");
        System.out.println(" +-> context=" + event.getServletContext());
    }


--- exnihilo <exnihilo@myrealbox.com> wrote:
> I need the variables in a ServletContextListener that gets invoked once 
> on startup and once on shutdown of the application, and don't need them 
> anywhere else. I used to have a subclassed ActionServlet, where I did 
> initialization and shutdown using a couple of init-params in the 
> web.xml, but then I realized that using the default ActionServlet and 
> using a ServletContextListener was cleaner, except that now the 
> init-params no longer work. Ideally, I would like something as simple as 
> including them in the web.xml..
> 
> Does anybody know the justification for preventing non-default 
> init-params from being seen when using the default ActionServlet? It 
> seems like a very easy solution to a very common need.
> 
> thanks,
> 
> n.
> 
> Hubert Rabago wrote:
> 
> >Where do you need the values?  There are a lot of options, including using
> >servlet context variables and a simple Struts plugin.
> >
> >--- exnihilo <exnihilo@myrealbox.com> wrote:
> >  
> >
> >>hi,
> >>
> >>I have 2 init-params that I need to do pass into my struts app (that are
> >>only used in a listener that gets called upon webapp startup and
> >>shutdown). I did the obvious and included them in the web.xml, but it
> >>seems that the default ActionServlet does not pick up any other
> >>init-params than the ones it expects (if I read the javadocs correctly),
> >>and that I need to subclass ActionServlet if I want to use other
> >>init-params than the default ones.
> >>
> >>Are there other options? It seems like overkill in this case, because
> >>the default ActionServlet is totally sufficient for my needs in all
> >>other regards. There is a probably a much better solution that I am not
> >>finding.
> >>
> >>Any ideas or pointers to more info?
> >>
> >>thanks,
> >>
> >>n.
> >>
> >>
> >>    
> >>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

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


Mime
View raw message