On 11 Sep 2002, Craig Longman wrote: > On Tue, 2002-09-10 at 19:53, Milt Epstein wrote: [ ... ] > > As to init parameters, I'm not sure what you're trying to do with > > them, but note that you can set up context parameters in the web.xml, > > and that you can get the context (via the getServletContext() method) > > from the ServletContextEvent that's passed to the context listener > > methods (so you can have access to the context parameters). You can > > also use a properties file, as others have suggested. > > yes, but calling getServletContext().getInitParameterNames() produces an > empty enumeration. when i said, 'i don't know what context i'm > receiving', i meant that there were no init parameters provided, but > there are definitely some in the one and only <servlet> section i have. > i guess i was assuming that the context listener was related to a > servlet. in retrospect now, i can see its not. > > so, i wonder if there is some way of getting init parameters into this > context that gets passed, the default context or something i guess. > > anyway, i've had to just hard code the filename into the listener, using > the ServletContext.getRealPath( "/" ) + "/WEB-INF/" directory. crazy.
Back to basics: A servlet container will have a bunch of contexts (aka web applications), and each context will have a bunch of servlets/JSPs (where "a bunch of" basically means "one or more"). Each context has a web.xml file, where you can specify context parameters, and define servlets, and specify init parameters for each such defined servlet (as well as lots of other fun stuff). Context parameters are specified via context-param tags, (servlet) init parameters are specified via init-param tags within a servlet tag. So note that there are context parameters and (servlet) init parameters, and they are different things. Context parameters can be gotten via ServletContext.getInitParameterNames(), and (servlet) init parameters can be gotten via GenericServlet.getInitParameterNames(). So, after saying all this, is it possible that you've specified some (servlet) init parameters, and not context parameters? (The fact that you say "there are definitely some in the one and only <servlet> section i have" further supports this conjecture.) That would explain why your call to getServletContext().getInitParameterNames() returns an empty enumeration. If so, go back and change them to context parameters, and try again (be aware of where context parameters must go in the web.xml, as tags there must go in a certain order; see the servlet spec for more info on that). > > > so, i'm a little bit further ahead, at least i have the preferred log to > > > write to, but still no convenient method of passing it configuration > > > parameters. i'm off to investigate if there is any mechanism in the > > > <listener> stuff that i can use. > > > > See above. It looks like Tomcat has some additional mechanisms for > > handling configuration parameters (e.g. Listener tags in the > > server.xml file, but that may make your set up not portable). > > it does. i have no idea why the architects of the whatever spec drives > the web.xml were so insistent on being as verbose as they were. doing > it the tomcat introspection way seems so sensible, and perfectly > flexible at the same time. Not sure what you're referring to here. Introspection/reflection is used to determine what kind of listener is specified in the web.xml file. Milt Epstein Research Programmer Integration and Software Engineering (ISE) Campus Information Technologies and Educational Services (CITES) University of Illinois at Urbana-Champaign (UIUC) [EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
