Re: Using init parameters
On Wed, Apr 21, 2004 at 15:28 +0530, Keith Hankin wrote: I have the following in my web.xml: context-param param-nameapplicationName/param-name param-valuetestApp/param-value /context-param My servlet class extends HttpServlet and has the following method: public void init(ServletConfig config) throws ServletException { super.init(config); configDir = getInitParameter(configDir); applicationName = getInitParameter(applicationName); System.out.println(configDir = + configDir); System.out.println(applicationName = + applicationName); jdbcAccess = new AddrJdbcAccess(configDir, applicationName); } Both calls to getInitParameter() return null. What's wrong here? You are asking for the servlet init parameter, use getServletContext().getInitParameter() to retrieve the init paramaters for a context. I found that confusing as well. -- Jens-Uwe Mager pgp-mailto:F476EBC2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using init parameters
Guess you are looking to access the context param init paramaters (as specified in context-param blocks). The servelt config's getInitParameter corresponds to the *servlet's* init parameters So guess you need to use getServletContext().getInitParameter(applicationName) rather than getInitParameter(applicationName) -Original Message- From: Keith Hankin [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 21, 2004 3:29 PM To: [EMAIL PROTECTED] Subject: Using init parameters I have the following in my web.xml: context-param param-nameapplicationName/param-name param-valuetestApp/param-value /context-param My servlet class extends HttpServlet and has the following method: public void init(ServletConfig config) throws ServletException { super.init(config); configDir = getInitParameter(configDir); applicationName = getInitParameter(applicationName); System.out.println(configDir = + configDir); System.out.println(applicationName = + applicationName); jdbcAccess = new AddrJdbcAccess(configDir, applicationName); } Both calls to getInitParameter() return null. What's wrong here? - 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: Using init parameters
That sort of works. The applicationName parameter is found now. However the configDir parameter is not found. This parameter is specified in server.xml as follows: Context path= docBase=ROOT debug=0 Parameter name=configDir value=C:\config override=false/ /Context I am sure that this context (the default context) should be used. - Original Message - From: Keith Hankin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 21, 2004 3:28 PM Subject: Using init parameters I have the following in my web.xml: context-param param-nameapplicationName/param-name param-valuetestApp/param-value /context-param My servlet class extends HttpServlet and has the following method: public void init(ServletConfig config) throws ServletException { super.init(config); configDir = getInitParameter(configDir); applicationName = getInitParameter(applicationName); System.out.println(configDir = + configDir); System.out.println(applicationName = + applicationName); jdbcAccess = new AddrJdbcAccess(configDir, applicationName); } Both calls to getInitParameter() return null. What's wrong here? - 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]