Config Implicit Object
Config Implicit Object
config object is an implicit object of type ServletConfig and it is created by the container, whenever servlet object is created. This object can be used to get initialization parameter for a particular JSP page.
config object is created by the web container for every jsp page. It means if a web application has three jsp pages then three config object are created.
In jsp, it is not mandatory to configure in web.xml. If we configure a JSP in web.xml then the logical name and init parameter given in web.xml file are stored into config object by the container.
config object is accessible, only if the request is given to the jsp by using its url pattern, but not with name of the jsp.
config object is accessible, only if the request is given to the jsp by using its url pattern, but not with name of the jsp.
Example of config implicit object
index.html
<form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form>
web.xml file
<web-app> <servlet> <servlet-name>Home</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>Home</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); %>