Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Saturday, December 1, 2007

How to use the Application Object in java



Using the Application Object



Using the Application Object


<%
Integer counter = (Integer)session.getAttribute("counter");
String heading = null;
if (counter == null) {
counter = new Integer(1);
} else {
counter = new Integer(counter.intValue() + 1);
}

session.setAttribute("counter", counter);

Integer applicationCounter = (Integer)application.getAttribute("applicationCounter");
if (applicationCounter == null) {
applicationCounter = new Integer(1);
} else {
applicationCounter = new Integer(applicationCounter.intValue() + 1);
}

application.setAttribute("applicationCounter", applicationCounter);
%>

You have visited this page <%=counter%> times.


This page has been visited by all users <%=applicationCounter%> times.

No comments: