Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Session Timeouut

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Session Timeouut

    hello Sir, I have to make a web application in which i have to give session timeout .

    means if screen is inactive for a particular period of time then automatically it should

    redirect to login page from where user has to login again to access the resources.

    I know filters are used for this but do not have the idea .

    will you plz give me the example for this task .

    will always be gratefull.


  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Session Timeouut

    Hi ,

    You can use filter for same and other option is try to read sessiontimeout from request scope and compare from your maximum session interval.

    Right some condtion there and if its is max then session interval , redirect on login page.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Location
    India
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Session Timeouut

    First you need to write down the following piece of code in web.xml :

    <session-config>
    <session-timeout>15</session-timeout>
    </session-config>


    Here we have set the session time out = 15 minute for the web application.

    Now you have to add following piece of code in all the servlets.
    HttpSession session = request.getSession(false); //return only the active sessin object
    if (session == null)
    {
    //redirect to login page
    }

    But this is a long way to implement the functionality.
    I will suggest you to use the filter for the same.

    cheers
    sharad

  4. #4
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Session Timeouut

    yes, I have used the code which is posted by u. But i want to redirect automatically. In my code redirecting is working, But i should refresh the browser.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,153
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Session Timeouut

    Please do not report your own post as spam in an effort to receive more attention. You have now spammed every moderator of the forum with a report email, which actually decreases your chances of getting help.

    It's only been a few hours. Be patient and give it a few hours, or better yet, ask a more specific question, let us know what you've done already, and we'll go from there. Notice that this forum is title "What's Wrong with My Code?" yet you have not posted any code.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Problem with Session maintenance in IE 8
    By rameshiit19 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 4th, 2012, 12:00 AM
  2. session in jsp
    By casperl90 in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: November 2nd, 2011, 11:53 AM
  3. Passing session ID over HttpURLConnection
    By zuzacat in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 20th, 2011, 09:18 AM
  4. How can i put session in Javascript?
    By rajani in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: July 8th, 2009, 12:46 PM