Hai Ashu,
You can do it as follows.
If want to manipulate everything in the cache(REMEMBER IF YOU RESTART THE SERVER THE INFORMATION WILL BE LOST) use the javax.servlet.ServletContext or the built in object "application" in jsp for storing your information please go through the following jsp code
<%@ page contentType="text/html" import="java.util.*"%>
<%
String userId=request.getParameter("userid");
HashMap login=(HashMap)application.getAttribute("LOGIN");
if(login==null)
{
application.setAttribute("LOGIN",new HashMap());
login=(HashMap)application.getAttribute("LOGIN");
}
Date lastLogin=(Date)login.get(userId);
if(lastLogin==null)
{
out.println("You are loging first time");
login.put(userId,new Date(System.currentTimeMillis()));
}
else
{
out.println("You logged on "+lastLogin.toGMTString());
login.put(userId,new Date(System.currentTimeMillis()));
}
%>
You could also use the cookies but if the client disables the cookie your attempt will be failed
Create a custom tag library to implement the logic that will be nice & professional