You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mailing List Servlet <se...@alinto.com> on 2003/09/19 17:10:35 UTC
Init Parameter
Hello everybody,
I started to learn servlets few times ago. Everything was working perfectly
until I tried to get my <init-param> from my web.xml file.
I receive all the time a null value when I ask the value of my parameter:
String driver = getServletConfig().getInitParameter("driver").
If I put the parameter in a <context-param>, no problem, it works.
String driver = getServletContext().getInitParameter("driver");
Can someone help me. Thanks
Kenny
Here is my web.xml file:
<web-app>
<context-param>
<param-name>driver</param-name>
<param-value>12345</param-value>
</context-param>
<servlet>
<servlet-name>techSupport</servlet-name>
<servlet-class>techSupportServlet</servlet-class>
<init-param>
<param-name>driver</param-name>
<param-value>54321</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>techSupport</servlet-name>
<url-pattern>/techSupport</url-pattern>
</servlet-mapping>
</web-app>
Re: Init Parameter
Posted by Mailing List Servlet <se...@alinto.com>.
Hello Jon,
I'm gonna try this..Look interesting..
Thanks a lot.
----- Original Message -----
From: "Jon Wingfield" <jo...@mkodo.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, September 19, 2003 5:26 PM
Subject: Re: Init Parameter
> Where in the code are you calling the method. If it's as an instance
> variable or in the servlet constructor then Tomcat hasn't yet inited the
> servlet and the getServletConfig() method doesn't behave as you are
> expecting. Of course, there's always the init(ServletConfig config)
> method. ;)
>
> Mailing List Servlet wrote:
>
> > Hello everybody,
> >
> > I started to learn servlets few times ago. Everything was working
perfectly
> > until I tried to get my <init-param> from my web.xml file.
> > I receive all the time a null value when I ask the value of my
parameter:
> > String driver = getServletConfig().getInitParameter("driver").
> >
> > If I put the parameter in a <context-param>, no problem, it works.
> > String driver = getServletContext().getInitParameter("driver");
> >
> > Can someone help me. Thanks
> > Kenny
> >
> > Here is my web.xml file:
> >
> > <web-app>
> > <context-param>
> > <param-name>driver</param-name>
> > <param-value>12345</param-value>
> > </context-param>
> >
> > <servlet>
> > <servlet-name>techSupport</servlet-name>
> > <servlet-class>techSupportServlet</servlet-class>
> >
> > <init-param>
> > <param-name>driver</param-name>
> > <param-value>54321</param-value>
> > </init-param>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>techSupport</servlet-name>
> > <url-pattern>/techSupport</url-pattern>
> > </servlet-mapping>
> > </web-app>
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Init Parameter
Posted by Mailing List Servlet <se...@alinto.com>.
Hello Jon,
I'm gonna try this..Look interesting..
Thanks a lot.
----- Original Message -----
From: "Jon Wingfield" <jo...@mkodo.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, September 19, 2003 5:26 PM
Subject: Re: Init Parameter
> Where in the code are you calling the method. If it's as an instance
> variable or in the servlet constructor then Tomcat hasn't yet inited the
> servlet and the getServletConfig() method doesn't behave as you are
> expecting. Of course, there's always the init(ServletConfig config)
> method. ;)
>
> Mailing List Servlet wrote:
>
> > Hello everybody,
> >
> > I started to learn servlets few times ago. Everything was working
perfectly
> > until I tried to get my <init-param> from my web.xml file.
> > I receive all the time a null value when I ask the value of my
parameter:
> > String driver = getServletConfig().getInitParameter("driver").
> >
> > If I put the parameter in a <context-param>, no problem, it works.
> > String driver = getServletContext().getInitParameter("driver");
> >
> > Can someone help me. Thanks
> > Kenny
> >
> > Here is my web.xml file:
> >
> > <web-app>
> > <context-param>
> > <param-name>driver</param-name>
> > <param-value>12345</param-value>
> > </context-param>
> >
> > <servlet>
> > <servlet-name>techSupport</servlet-name>
> > <servlet-class>techSupportServlet</servlet-class>
> >
> > <init-param>
> > <param-name>driver</param-name>
> > <param-value>54321</param-value>
> > </init-param>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>techSupport</servlet-name>
> > <url-pattern>/techSupport</url-pattern>
> > </servlet-mapping>
> > </web-app>
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
Re: Init Parameter
Posted by Jon Wingfield <jo...@mkodo.com>.
Where in the code are you calling the method. If it's as an instance
variable or in the servlet constructor then Tomcat hasn't yet inited the
servlet and the getServletConfig() method doesn't behave as you are
expecting. Of course, there's always the init(ServletConfig config)
method. ;)
Mailing List Servlet wrote:
> Hello everybody,
>
> I started to learn servlets few times ago. Everything was working perfectly
> until I tried to get my <init-param> from my web.xml file.
> I receive all the time a null value when I ask the value of my parameter:
> String driver = getServletConfig().getInitParameter("driver").
>
> If I put the parameter in a <context-param>, no problem, it works.
> String driver = getServletContext().getInitParameter("driver");
>
> Can someone help me. Thanks
> Kenny
>
> Here is my web.xml file:
>
> <web-app>
> <context-param>
> <param-name>driver</param-name>
> <param-value>12345</param-value>
> </context-param>
>
> <servlet>
> <servlet-name>techSupport</servlet-name>
> <servlet-class>techSupportServlet</servlet-class>
>
> <init-param>
> <param-name>driver</param-name>
> <param-value>54321</param-value>
> </init-param>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>techSupport</servlet-name>
> <url-pattern>/techSupport</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Init Parameter
Posted by Jon Wingfield <jo...@mkodo.com>.
Where in the code are you calling the method. If it's as an instance
variable or in the servlet constructor then Tomcat hasn't yet inited the
servlet and the getServletConfig() method doesn't behave as you are
expecting. Of course, there's always the init(ServletConfig config)
method. ;)
Mailing List Servlet wrote:
> Hello everybody,
>
> I started to learn servlets few times ago. Everything was working perfectly
> until I tried to get my <init-param> from my web.xml file.
> I receive all the time a null value when I ask the value of my parameter:
> String driver = getServletConfig().getInitParameter("driver").
>
> If I put the parameter in a <context-param>, no problem, it works.
> String driver = getServletContext().getInitParameter("driver");
>
> Can someone help me. Thanks
> Kenny
>
> Here is my web.xml file:
>
> <web-app>
> <context-param>
> <param-name>driver</param-name>
> <param-value>12345</param-value>
> </context-param>
>
> <servlet>
> <servlet-name>techSupport</servlet-name>
> <servlet-class>techSupportServlet</servlet-class>
>
> <init-param>
> <param-name>driver</param-name>
> <param-value>54321</param-value>
> </init-param>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>techSupport</servlet-name>
> <url-pattern>/techSupport</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>