Results 1 to 10 of 10
  1. #1
    shivakumari is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default terminating the page if user sits idle.

    Hi..
    I want to redirect to loginpage if the user sits idle without doing for few minutes after login.I need servelet code for this.
    Can u help me..

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Add in web.xml this for 25 minutes session:

    Java Code:
    <session-config>
    <session-timeout>25</session-timeout> 
    </session-config>

  3. #3
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Or create SessionListener class which implements ServletContextListener,
    HttpSessionAttributeListener, HttpSessionListener and then in web.xml add:
    Java Code:
    <listener>
            <listener-class>SessionListener</listener-class>
        </listener>

  4. #4
    shivakumari is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default Thanks for your response.

    I placed the below code after <server-mapping> tags in web.xml file of my application .
    <session-config>
    <session-timeout>25</session-timeout>
    </session-config>

    Still it is not displaying the login page after the session time out.
    Is there any code need to add.But how the application knows to display the login page when session is timed out.
    please help me..

  5. #5
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    server only response when client make request....
    if client idle, even session time out, server can not redirect client to other page

    you may use database with sessionid, last_activity_time and settimeout javascript function to check...
    Last edited by mtyoung; 04-03-2009 at 10:01 AM.

  6. #6
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    No no, create SessionListener class as i told you and in method destroy make response.sendRedirect("login.jsp");

  7. #7
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Ah yes and of course register that listener class in web.xml in <session-listener> tags

  8. #8
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    problem is .... if user do not make any request, how can you response to user?

  9. #9
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    To response to user that the session is over?

  10. #10
    shivakumari is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default thank you for your reply

    Hi..
    Thanks.I will try it using session listener class...bye.

Similar Threads

  1. Go back to previous page using session in JSP page
    By gopikarikati009 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-23-2011, 10:30 AM
  2. forcibly terminating io operations
    By arnab321 in forum CLDC and MIDP
    Replies: 2
    Last Post: 11-15-2008, 08:51 PM
  3. Replies: 3
    Last Post: 11-06-2008, 04:24 PM
  4. warning that page has expired and i need to refresh the page again
    By 82rathi.angara in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 07-15-2008, 01:48 PM
  5. terminating a while loop with a string
    By tkdvipers in forum New To Java
    Replies: 3
    Last Post: 07-09-2007, 11:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •