CodesJava

Easy learning with example program codes

JSP application implicit object

JSP application object is an instance of javax.servlet.ServletContext. This object is used to get initialization parameters defined in web.xml.

Example:

index.jsp

<html>
	<head>
		<title>application implicit object example</title>
	</head>
	<body> 
	     <h3>To see the website name click on the below link.</h3>
	     <a href="welcome.jsp">Click here</a>
	</body>
</html>

welcome.jsp

<html>
	<head>
		<title>application implicit object example</title>
	</head>
	<body> 
		<%
		  String companyWebsite = 
                    application.getInitParameter("companyWebsiteName"); 
		  out.print("Company website: " + companyWebsite);
		%>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 22 index
 
Click on the link.
jsp example 22 display
 
Download this example.
 
Next Topic: JSP session implicit object with example.
Previous Topic: JSP config implicit object with example.

 

Please follow and like us:
error
Posted in JSP   








Copyright © 2019 CodesJava DMCA.com Protection Status