Introduction:
Web.xml
Welcome.jsp
1. The config object allows you to access the initialization parameters for the Servlet and JSP engine.
2. The config object is an instance of the class javax.servlet.ServletConfig.
3. all methods of ServletConfig interface we can apply on config also
following is the list of applicable methods.
§ getInitParameter ( )
§ getInitParameterNames()
§ getServlerName()
Example: index.html
<html> <body> <input type = "text" name = 'uname'/> <input type = "submit" name = 'go'/> </body> </html> |
Web.xml
<web-app> <servlet> <servlet-name>action</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>action</servlet-name> <url-pattern>/welcome</url-pattern> </servlet-mapping> </web-app> |
Welcome.jsp
<html> <body> <% out.print("welcome"+request.getParameter("uname")); String driver = config.getParameter("dname"); out.print("driver name is ="+driver); %> </body> </html> |
Nice tutorials
ReplyDelete