This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hi, What I want to do is that when a person logs in on my site I want to provide him with the date he last logged in.. How can that be done??? I am using JSP for coding while HttpSession class is being used for session tracking... Could anybody tell on how this can be done... I shall be thankful. THANKS ASHU
Rehan Malik
Ranch Hand
Joined: Jul 09, 2001
Posts: 76
posted
0
Originally posted by ashu goel: hi, What I want to do is that when a person logs in on my site I want to provide him with the date he last logged in.. How can that be done??? I am using JSP for coding while HttpSession class is being used for session tracking... Could anybody tell on how this can be done... I shall be thankful. THANKS ASHU
You pretty much have two options. You can either add a cookie which holds the last login date/time or you can save that information on YOUR server. I would prefer the cookie method over saving it on your server for obvious reasons.
Rehan Malik
Anoop Krishnan
Ranch Hand
Joined: May 03, 2001
Posts: 163
posted
0
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
I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla