1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

session management??

Discussion in 'JSP' started by adroit89, Apr 19, 2010.

  1. adroit89

    adroit89 New Member

    how to manage sessions in JSP. I want to create a session as soon as user logs in and disable the session when he logs out. I also want to disable back button so that when he presses back button login page has to be opened.
     
  2. satyedra pal

    satyedra pal New Member

    When a user open the broser and done some work or some change and then close the browser then
    it will be stored in cookie and also called the session time in which user access the browser.You can get session ID in jsp by using session.getId() and can set the session user by using session.setAttribute("Session",setsession),
    When user does their work complete and want to close browser,It is called expire or destroy the session.You can find the session starting and ending using session.getCreationTime() and session.getLastAccessedTime() respactively.
    JSP Stores and Retrieves Session Variables as thje following:

    <% @page import = "java.util.Date" session="true"%>
    <html>
    <body>
    <p>JSP (java server page) are required following</p>
    String name="satya";
    session.setAttribute("username",name);
    String user=session.getAttribute("username");
    out.println("Hello" +user);
    Session ID of user in JSP : <%session.getId()%><br>
    Started time of session in JSP<%new Date(session.getCreationTime())%><br>
    expiry time of session in JSP<%new Date(session.getLastAccessedTime())%>
    </body>
    </html>
     

Share This Page