Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

JSP config


In JSP, config is an implicit object of type ServletConfig. This object can be used to get initialization parameter for a particular JSP page. The config object is created by the web container for each jsp page.

Generally, it is used to get initialization parameter from the web.xml file.

Example of config implicit object:

index.html

  1. <form action=“welcome”>
  2. <input type=“text” name=“uname”>
  3. <input type=“submit” value=“go”><br/>
  4. </form>

web.xml file

  1. <web-app>
  2. <servlet>
  3. <servlet-name>sonoojaiswal</servlet-name>
  4. <jsp-file>/welcome.jsp</jsp-file>
  5. <init-param>
  6. <param-name>dname</param-name>
  7. <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
  8. </init-param>
  9. </servlet>
  10. <servlet-mapping>
  11. <servlet-name>sonoojaiswal</servlet-name>
  12. <url-pattern>/welcome</url-pattern>
  13. </servlet-mapping>
  14. </web-app>

welcome.jsp

  1. <%
  2. out.print(“Welcome “+request.getParameter(“uname”));
  3. String driver=config.getInitParameter(“dname”);
  4. out.print(“driver name is=”+driver);
  5. %>

Output

config1

config2

Comments

comments