Solved

How to Handle session time out in JSP?

Posted on 2011-02-24
7
1,705 Views
Last Modified: 2012-05-11
Hi All,

I am having a problem with session time out, can anyone please suggest me on how to handle session time out using spring. I am using weblogic as app server. I want to throw an error page when session has timed out.

Thanks
Pavan
0
Comment
Question by:Gangadhara Melukote
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 2

Accepted Solution

by:
ramkihardy earned 250 total points
ID: 34968273
This works for me

<session-management invalid-session-url="/taac/login">
    <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</session-management>

Here's how I typically do it. On every AJAX call, check the result before using it.

$.ajax({ type: 'GET',
    url: GetRootUrl() + '/services/dosomething.ashx',
    success: function (data) {
      if (HasErrors(data)) return;

      // process data returned...

    },
    error: function (xmlHttpRequest, textStatus) {
      ShowStatusFailed(xmlHttpRequest);
    }
  });
And then the HasErrors() function looks like this, and can be shared on all pages.

function HasErrors(data) {
  // check for redirect to login page
  if (data.search(/login\.aspx/i) != -1) {
    top.location.href = GetRootUrl() + '/login.aspx?lo=TimedOut';
    return true;
  }
  // check for IIS error page
  if (data.search(/Internal Server Error/) != -1) {
    ShowStatusFailed('Server Error.');
    return true;
  }
  // check for our custom error handling page
  if (data.search(/Error.aspx/) != -1) {
    ShowStatusFailed('An error occurred on the server. The Technical Support Team has been provided with the error details.');
    return true;
  }
  return false;
}

If this is useful mark it as solution
With Regards............
0
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 250 total points
ID: 34968482
Put this code in your web.xml file
       <session-config>      
                 <session-timeout>180</session-timeout>  
             </session-config>

add this line in ur dispatcher servlert xml

Put some property entry which go to your sessionexpiry page or login page
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34968505
or use Interceptor concept to redirect ur login page the have perhandling and post handling method so it will check every time your session and redirect to original page or session expiry page
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35147051
User didnt mention his solution .  I have mention the correct solution .
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35221433
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exception creating bean of class 5 219
struts exact match support 3 59
how to debug htl and js pages 8 54
dao vs facade design patterns 2 33
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question