Advertisement
Methods | Description |
---|---|
Object getAttribute(String name | This method gets an object stored in a session with a name, or null. |
void setAttribute(String name, Object value) | This method sets an object with a name in a session. |
void removeAttribute(String name) | This method removes an object with a name from the session. |
ServletContext getContext(String path) | This method returns a ServletContext object that corresponds to a specified URL. |
RequestDispatcher getRequestDispatcher(String filePath) | This method returns a RequestDispatcher which acts as a wrapper for the resource at the path. |
void setMaxInactiveInterval(int seconds | This method sets the time between client requests before the servlet container invalidates the session. |
long getCreationTime() | This method gets the creation time of the current session, since 1970 in milliseconds. |
ServletContext getServletContext() | This method returns the ServletContext to the current session. |
boolean isNew() | This method gives a true if the current session is new and client doesn't know about it. |
Advertisement
<html>
<head>
<title>Using JSP application object</title>
</head>
<!-- html opening body tag starts here -->
<body
<%
Object ob = application.getAttribute("Background_Color");
boolean bool=false;
if(ob==null)
{
bool=true;
}
else
{
out.println("bgcolor =" + application.getAttribute("Background_Color"));
}
if(bool)
{
application.setAttribute("Background_Color", "pink");
}
%>
> <!-- html opening body tag ends here -->
<h1>Setting and accessing application object</h1>
This page will set its background color using implicit application object of JSP.
</body>
</html>
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement