Please share a working example of session maintenance in JSP.

This example describes how to use the HttpSession object to find out the creation time and the last-accessed time for a session. We would associate a new session with the request if one does not already exist.




   
      Session Tracking
   
   
      
     

Session Tracking

   
   
                                                                                                                                                                                                     
Session infoValue
id
Creation Time
Time of Last Access
User ID
Number of visits
   

Now put the above code in main.jsp and try to access http://localhost:8080/main.jsp. Once you run the URL, you will receive the following result −

Welcome to my website

Session Information

Session info value
id 0AE3EC93FF44E3C525B4351B77ABB2D5
Creation Time Tue Jun 08 17:26:40 GMT+04:00 2010
Time of Last Access Tue Jun 08 17:26:40 GMT+04:00 2010
User ID ABCD
Number of visits 0
Updated on: 2019-07-30T22:30:25+05:30

352 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements