G'day, I assume from this that init parameters can only be accessed by a listener if they have been declared globally within the applications context and not from within the scope of the listener itself?
Hmmmmm.... AB -----Original Message----- From: Frank Burns [mailto:[EMAIL PROTECTED] Sent: Monday, 15 March 2004 12:30 AM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Passing init params to a listener? For each parameter you need your listener to read, place name/value pairs in your web.xml. Here's an example for two parameters (mySQLServerName and mySQLPort): <context-param> <param-name> mySQLServerName </param-name> <param-value> localhost </param-value> </context-param> <context-param> <param-name> mySQLPort </param-name> <param-value> 3306 </param-value> </context-param> Then, in your listener class, read them like this: String serverName = application.getInitParameter("mySQLServerName"); String mySQLPort = application.getInitParameter("mySQLPort"); ----- Original Message ----- From: "Adrian Beech" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, March 11, 2004 2:07 PM Subject: Passing init params to a listener? G'day all, Can someone please advise how to pass init params to a listener? For example, in my web.xml file I have the following listener currently defined as:- <listener> <listener-class>czone.db.InitConnectionPool</listener-class> </listener> At the moment all parameters are hard coded in the listener. If I want to extend the flexibility of the code by adding init parameters to the listener definition do I merely do this:- <listener> <listener-class>czone.db.InitConnectionPool</listener-class> <init-param> <param-name>jdbcConnectionString</param-name> <param-value>...</param-value> </init-param> </listener> If this is correct then what Java code is required in the contextInitialized(...) method to pull the init parameter name and value so the listener can use it? I really don't have a clue what I'm doing so some guideance on this matter would be greatly appreciated! Thanks if you can help. AB --------------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
