I have application wide single controller.
@RequestMapping(method = RequestMethod.POST,value="services")
@ResponseBody
mwpWebServices(@RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws JSONException, UnknownHostException, MongoException
{
HttpSession session = request.getSession();
......
String method = jsonObj.getString("method");
....
if(method.equals("login"))
{
someClassObj.login(params);//which stores some value in session variable "somevar"
}
if(method.equals("other"))
{
System.out.println(session.getAttributes("somevar"));//coming null
}
}
now “data” will recieve JSON String
and I will parse in into JSONObject that will look like
{“method”:”login”,”action”:”Auth”,”params”:”Some data”}
now when method is login
i call some method of another class to which I pass session object which store some value in session
but when next time when request comes, session varible doesn’t persist value…
HttpSession of requires the client i.e. Browser to store the session id in cookie.
So my browser’s cookie was off, that’s why each request was bringing new session id