Contact Us
   
   
 
   
   
 
     
 
 
JSP Tutorial
 
Book Must Read
 
 

JSP Application Object

 
 
Print   Email
 
     
 

JSP application is computer program designed for specific task and solution. This application can contain JSP, Servlet, xml, class files, and jar files. Suppose  a shopping store has a software to sale, buy, purchase, shipping products, payments, upload new products, all these belongs to single store. This single unit is called application. All files (JSP) work together to perform specific task.
The application object is used to store and retrieve from any page of JSP or any where in application scope. This is something like session object, but session object is made for per user. And no other user can access session object of other user. Application object is available to all, can be access by all users, because it is single object.

Store and Retrieve Application Variables

JSP use in application objects ServletContext object. This object also contain values of session object and available to all. Another one is application object. We will see in example of this application object in JSP

applicationObject.jsp

<%@ page language="java" import="java.sql.*" %>
<%
String parameterValue="This is application object";
    
    getServletContext().setAttribute("ApplicationValue","This is my Name");
    String getValueApplcation=(String)getServletContext().getAttribute("ApplicationValue");
    
    application.setAttribute("ApplcationVariable",parameterValue);
    String getApplicationVariable=(String)application.getAttribute("ApplcationVariable");
%>
<html>
<head>
<title>Applcation object in JSP</title>
</head>

<body>
The value of getting getServletContext application object <%=getValueApplcation%><br>
This is application object :<%=getApplicationVariable%>
</body>
</html>

Application object handling is same as session object handling. This is done by servlet container

Method Return Description
equals(Object obj) Objects Matching objects
getAttribute(String str) Objects Getting value through application objects
getAttributeNames() Enumeration an Enumeration of attribute names
getContext(String str) ServletContext  
getContextPath() String  
getInitParameter(String str) String  
getInitParameterNames() Enumeration  
getMajorVersion() int  
getMimeType(String str) String  
getMinorVersion() int  
getNamedDispatcher(String str) RequestDispatcher  
getRealPath(String str) String  
getRequestDispatcher(String str) RequestDispatcher  
getResource(String str) URL  
getResourceAsStream(String str) InputStream  
getResourcePaths(String str) Set  
log(String str) void  
log(String str, Throwable t) void  
removeAttribute(String str) void  
setAttribute(String str, Object obj) void  
toString() String  

 

 

 

 
If You Like this Article, share this

 
 
     
   
  View Forum Post  
 
Optimization of SQL queries for better performance
Example of Between in mysql
Example of sorting in mysql table
Example of join in mysql
Example of subquery in mysql
union join in mysql with example
error too many connection in mysql
calculate second highest salary
How to use select queries with array in mysql
Radio button pre selected in struts
Exception in thread "main" java.lang.NoClassDefFoundError
tree view in jsp
SSL implement in tomcat and java certificate
WARNING: Internal error flushing the buffer in release()
DynaForm validation problem in struts not working
Accessing JavaBean in servlet or servlet in javaBean.
 
 
     
     
     
 
  Privacy Policy