JSP config implicit object
JSP config implicit object is instance of javax.servlet.ServletConfig.
The JSP config object is created by the web container for each jsp page.
The JSP config objectis mainly used for accessing initialization parameter from the web.xml file.
Example of config implicit object:
index.html
<html>
<body>
<form action="first">
<input type="text" name="uname">
<input type="submit" value="Click"><br/>
</form>
</body>
</html>
web.xml file
<web-app>
<servlet>
<servlet-name>demo</servlet-name>
<jsp-file>/first.jsp</jsp-file>
<init-param>
<param-name>name</param-name>
<param-value>Abhishek kumar</param-value>
</init-param>
<init-param>
<param-name>email</param-name>
<param-value>gkvstudent@gmail.com</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>demo</servlet-name>
<url-pattern>/first</url-pattern>
</servlet-mapping>
</web-app>
first.jsp
<%
out.print("Welcome "+request.getParameter("uname"));
String name=config.getInitParameter("name");
String emailid=config.getInitParameter("email");
out.print("Name="+name);
out.print("Email-Id="+emailid);
%>
[…] config Object […]
LikeLike
very nice jsp tutorial
LikeLike