Here it is.
Main Topics
Browse All TopicsI got a solution from one of the expert and was able to implement it also. What i want to do is keep the session alive for long forms. However, i can see that the JS function does hit my servlet but unfortunately the session still gets destroyed after default 30 min time instead of being extended. I do have a HttpSessionListener class which is set to default 30 min.
I added some log statements to see when the session is created and destroyed and it gets destroyed after 30 min. However when it reached 29 min i tried going to another page and everything works great.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Also there are differences between <session-timeout> setting in web.xml and using setMaxInterval().
A session which has setMaxInterval() would automatically get expired after the time specified, whereas for those session that doesn't have setMaxInterval() it looks for default <session-timeout> application setting in web.xml and based on that it expires.
I hope in your case since setMaxInterval() is set it doesn't have an idea of what value to reset the session.
Alternatively u can remove the setMaxInterval() from ur HttpSessionListener & ur Pingsession servlet(if u added that setMaxInterval()) and configure it in web.xml and then give it a try then it should work like a gem.
-Murali*
I tried adding setMaxInterval in my Ping Servlet but unfortunately the result is the same. It does not extend the session. I don't know what the main reason is. I am trying one more trick to see if that will help. if not then i will remove the listener from web.xml and will configure the session-timeout in web.xml which will be set to 30 min and then i will see if that will work or not. Thanks for your help. I will update later on.
that stumped me all together. Fine, are you using Spring WebMVC and its controller for ur page request?
If yes can u try pointing the .js to the controller and handle the session handling code there instead of a seperate servlet?
since u already have a parameter pageKey=extendSession, you can add the following (if) in the controller and then copy the rest of the session extending code.
if("extendSession".equalsI
//create xml and flush it.
}
I have the same set of code , running on a Tomcat server and its working perfectly. What server do you use?.
-Murali*
I used Sun one web server. In the meantime i read about XMLHttprequest and the JS function is working properly. Session will always be renewed when you hit a server doPost() method. however, In my case who knows what might be wrong and why it is not renewing the session.
Our login page is a servlet where as the page which is long is a controller. I am still trying to see why
<session-config>
<session-timeout>30</sessio-t
</session-config>
is not working.
@Micheal:
Any luck?. I just gone through different sites but couldnt find something useful for this issue.
Just a wierd one was check if u use acegi.jar (try replacing with the latest one).
I would suggest a workaround for this problem,
Instead of servlet (PingSession) you pass the control to one of the Spring Controllers (dummy) probably which is empty and doesn't do anything (dont frwd to any target page).
Give it a try...
-Murali*
Just curious murali. So now as i understand you i will create a simple controller using spring framework. I can probably use handlerequestInternal method of the controller to do exactly what i was doing in PingSession servlet. I will do :-
String param = request.getParameter("page
If pageKey is extendSession then
do all the XML stuff what i did in my servlet.
My only question is that what do i need to do over here ? :-
req.onreadystatechange = getReadyStateHandler(req, updateSessionInfo);
req.open("POST", "/servlet/PingSession", true);
As the controller is suppose to be defined in applicationContext if you want to make it available in the application. Thank you for all your help man in solving this wiered issue. I can't find anything in the code itself to see why is it not extending the session :(
I tried to use the same controller. When i added this :-
req.open("POST","/jsp/addU
I get an error stating :-
"Neither bindingresult nor command object user is available as request". I know this is the most common error in spring but how can i get rid of it ?. I put the xml code in refrenceData as refrenceData is always called when a page refreshes as per spring documentation. I think my problem is the frames.
hmm . Creating a Controller in spring and then calling the JSP and resetting the session time in the controller through AJax have done the trick for me :).
I can stay on the same page as long as i want to now :--). However, i have only one question murali. This function :-
function updateSessionInfo(sessionX
var session = sessionXML.getElementsByTa
var userid = session.getAttribute("user
if(userid == 'null' || userid == null){
msgToUser();
}
}
When i try to put alert statement i get 'null or no object' in this method. I putted aler(session) and i got null over there also. The code does send the request to my controller but since it is a MVC and i am using just a simpleformcontroller i don't know what to return ?
return new ModelAndView(getSuccessVie
I believe this is my problem that is why i am not getting anything in the response in AJAX. Any tips ?
Glad that you are successful in making an AJAX call.
Actually you need not to return anything from the controller unless u need to show an alert to the user.
So i just browsed few items and got this for how to return an xml from Spring Controller. See if it helps,
http://www.extjs.com/forum
http://forum.springsource.
-Murali*
Hmm. Well that is true also i do'nt want to show anything to the user in the alert statement except for just that pop up message. However if i just leave it like the way it is everything works fine also but i get a Javascript error. I am trying to see what can i remove from the ajax code so that the JS error is not shown to the user in the task bar,
Thanks for your help murali. I am still stuckon this problem and i plan to do more research later on and will try to find an appropriate solution. If i keep hitting the serer after every 5 min everything works fine if the server stays idle for more than 10 min then no matter what i do the session gets destroyed. I will add comments in this post if i need any input from you. Thanks for all your help man. BTW i like your blog and have started supporting it. You are a great helper and very knowledged guy.
Business Accounts
Answer for Membership
by: MuraliKanthPosted on 2009-10-05 at 18:35:54ID: 25501274
Hi Micheal,
Could you please post your HttpSessionListener class code. Just i wanted to give it a try on my machine.
-Murali*