JSP application object
JSP application implicit object is instance of javax.servlet.ServletContext.
The instance of ServletContext is created only once by the web container.it is use to get configuration information from web.xml file .
JSP config implicit object get information from <init-param> tag of web.xml file but JSP application implicit object get information from <context-param> tag of web.xml.
Example of application 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>
</servlet>
<servlet-mapping>
<servlet-name>demo</servlet-name>
<url-pattern>/first</url-pattern>
</servlet-mapping>
<context-param>
<param-name>name</param-name>
<param-value>Abhishek kumar</param-value>
</context-param>
</web-app>
first.jsp
<%
out.print("Hello "+request.getParameter("uname"));
String name=application.getInitParameter("name");
out.print("Name="+name);
%>
[…] application Object […]
LikeLike