logo

JSP Config Implicit Object


Show

In JSP, config is an implicit object of writing ServletConfig. This object can be made in use to have initialization parameters for a specific JSP page. The config object is generated by the web container for each and every JSP page.

In General, it is made in use to have an initialization parameter from the web.xml file.

Example of config implicit object:

index.html

<form action="welcome">  
<input type="text" name="uname">  
<input type="submit" value="go"><br/>  
</form>

web.xml file

<web-app>  

<servlet>  
<servlet-name>sonoojaiswal</servlet-name>  
<jsp-file>/welcome.jsp</jsp-file>  
  
<init-param>  
<param-name>dname</param-name>  
<param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>  
</init-param>  

</servlet>  

<servlet-mapping>  
<servlet-name>sonoojaiswal</servlet-name>  
<url-pattern>/welcome</url-pattern>  
</servlet-mapping>  

</web-app>  
welcome.jsp
<%   
out.print("Welcome "+request.getParameter("uname"));  
  
String driver=config.getInitParameter("dname");  
out.print("driver name is="+driver);  
%>  

Output