How to configure ServletConfig in web.xml? - Java @ Desk

Tuesday, May 21, 2013

How to configure ServletConfig in web.xml?







ServletConfig is configured in web.xml and parameters in this mapping is accessible to this servlet only





<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>com.MyClass</servlet-class>

<init-param>
<param-name><b>email</b></param-name>
<param-value>admin@email.com</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/Demo</url-pattern>
</servlet-mapping>
Get init param of servlet using : getServletConfig().getInitParameter("email")






No comments:

Post a Comment