I need to retrieve init-param value from xml to Servlet i used following code
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
</servlet>
servlet code
public void init(ServletConfig config) throws ServletException {
super.init(config);
System.out.println(config.getInitParameter("jdbcDriver"));
}
But It displayed null .. could any one help me to do that . thanks in advance
I can't see a single reason, why you have to override your init(ServletConfig sc)
method, since you can always get your ServletConfig
by calling your inherited getServletConfig()
method.
System.out.println(getServletConfig().getInitParameter("jdbcDriver"));