Re: non-default init-params and default ActionServlet
That is exactly what I'm trying to do, but when I try getInitParameterNames, I get an empty enumeration, and if I read the javadocs correctly, it is because if I use a default ActionServlet, then only the init-params mentioned in the javadocs are available, so my custom init-params are not there. I'm using Tomcat 5.0.18, if that makes a difference, and it's possible i'm doing something else wrong, but the app seems to load fine, the contextlistener gets called, but when I try to get the initparams within contextInitialized, I get only an empty enumeration. thanks, n. Hubert Rabago wrote: 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: non-default init-params and default ActionServlet
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: non-default init-params and default ActionServlet
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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: non-default init-params and default ActionServlet
Where do you need the values? There are a lot of options, including using servlet context variables and a simple Struts plugin. --- exnihilo <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]