RE: How to get session attribute from different RESt builder different APIs

تم تعديل RAVI RAJAMANI منذ 5 سنوات من الدقائق. Regular Member المشاركات: 123 تاريخ الإنضمام: 7‏/12‏/14 المشاركات الحديثة
How to get session attributes from different modules , RESTbuilder API modules.

say Module1 and Module2

In Module1 i had saved session value like below

HttpSession httpSession = contextHttpServletRequest.getSession(true);
httpSession.setAttribute("fooKey", "fooValue");

In Module2 i had getting session value like below
HttpSession httpSession = contextHttpServletRequest.getSession(true);
String value = (String) httpSession.getAttribute("fooKey")
System.out.println(value); // null is coming
Getting null , cannot able to getAttribute from different module
thumbnail
تم تعديل David H Nebinger منذ 5 سنوات من الدقائق. Liferay Legend المشاركات: 14933 تاريخ الإنضمام: 2‏/9‏/06 المشاركات الحديثة
You should not do this. The APIs are intended to be stateless. They are not built to support maintaining state across calls.
تم تعديل RAVI RAJAMANI منذ 5 سنوات من الدقائق. Regular Member المشاركات: 123 تاريخ الإنضمام: 7‏/12‏/14 المشاركات الحديثة
David H Nebinger:

You should not do this. The APIs are intended to be stateless. They are not built to support maintaining state across calls.
Is there any other way to achieve like this ? 
thumbnail
تم تعديل Christoph Rabel منذ 5 سنوات من الدقائق. Liferay Legend المشاركات: 1555 تاريخ الإنضمام: 24‏/9‏/09 المشاركات الحديثة
When you use rest calls, the application is usually the client and the application state is then held in the browser. The other option is to store only a key in the application and the rest of the information in the database.
Even if you find a momentary way around this, e.g. by using a cache or singleton + hash, believe me, it probably will bite you later on.