I am using eclipse for my project development. I basically created a web.xml file in the WEB_INF folder and added the following within the webapp tags
<
servlet>
<servlet-name>MyTestInit</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
<init-param>
<param-name>email</param-name>
<param-value>
kick@wicked.com</param-value>
</init-param>
</servlet>
<context-param>
<param-name>email</param-name>
<param-value>
test@test.com</param-value>
</context-param>
I also made a
jsp file BasicCounter.jsp in the context root and tried to access the servlet init parameter using
<%
String email = config.getInitParameter("email");
out.println("Email id is :" +email+"<br>");
%>
but all it returned is Null;
I was however able to access the context init parameter in the same jsp file using the following
<% String email1 = application.getInitParameter("email");
out.println("Email id is :" +email1+"<br>");
%>
and get the output
test@test.com
Am I doing anything wrong while trying to access the servlet init parameters?