Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring jQuery form submit request.getSession(false) returns session but with a new session id

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry, in case I have posted my query to irrelevant forum.
My problem is mentioned below.

I have a Spring 2.5 MVC based application with JPA(Hibernate) as persistence implementation.
I am facing a wierd problem as described below:

I have a Login Controller which contains the custom user authentication method for authenticating the user.
When the user is successfully authenticated I am manually setting the user's id, role and its name as found from
database in new HttpSession(using request.getSession(true)).Now when I navigate some pages in my application and Debug the flow in
other controllers, I check at desired places if user's id is available in the session.If yes, then proceed furhter
else redirect the user to authentication page.IN ALL THE DEBUGGED CONTROLLERS I GET THE SAME UNIQUE SESSION ID I FOUND WHEN THE USER"S AUTHENTICATION
WAS SUCCESSFUL IN MY LOGIN CONTROLLER.


However in the application in the front-end I have a JSP page which contains some details to be filled up by the user
and submitted to save the changes in the database.Initially when the page loads this form element is empty.For e.g as follows:



I am using latest version of jQuery in the application and I have binded the click event on 'Save Changes' button when the document gets ready.
From my callback function I have shown the required code snippet.



When the 'Save Changes' button is clicked and the form is submitted in the manner shown above, in my controller code when i do
request.getSession(false), I get a session but this time the session id is found NEW and not the one found in the controller when debuuged before
before the above form was submitted in the manner shown above.

IN FACT I PUT A BREAKPOINT IN SPRING'S DISPATCHERSERVLET.JAVA METHOD'S ENTRY POINT.AT THAT POINT ITSELF I AM GETTING THE
SESSION(REQUEST.GETSESSION(FALSE) BUT WITH A NEW SESSION ID WHICH MEANS A NEW SESSION GOT CREATED.
I am not able to understand why is it behaving this way.

NOTE:
1) This was the thing observed in Internet Explorer 6 and 7 browsers however in Mozilla Firefox 3.x version this problem does not occur and the
functionality works expected.

2) I have not configured session configuration explicitly in my web.xml.This is my web.xml.



Can anybody help me or guide me in resolving this problem?

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic