Forums de discussion

Get attribute value from httpsession object

robin thakur, modifié il y a 7 années.

Get attribute value from httpsession object

Regular Member Publications: 146 Date d'inscription: 09/01/14 Publications récentes
Hi,

I am facing a problem regarding getting value from httpsession object as the value is there in object but when I am fetching I am getting null.
Please find the attched screenshot as you see value is there but I am unable to fetch this. Help me to come out of this.
One more thing I already use <private-session-attrbute>false in liferay-portlet.xml.

Pièces jointes:

thumbnail
Kailash Yadav, modifié il y a 7 années.

RE: Get attribute value from httpsession object

Regular Member Publications: 211 Date d'inscription: 18/10/11 Publications récentes
Can you explain bit more? where are you adding session (in same portlet where you trying to access it or in other portlet)? Also it will good if you post code snippet of adding and getting session value.
robin thakur, modifié il y a 7 années.

RE: Get attribute value from httpsession object

Regular Member Publications: 146 Date d'inscription: 09/01/14 Publications récentes
Hi Kailash,

I add session attribute in Hook.
public void run(HttpServletRequest request, HttpServletResponse response)

And get the session attribute in portlet doView method

HttpServletRequest httpReq =
PortalUtil.getHttpServletRequest(renderRequest);
HttpServletRequest req = PortalUtil.getOriginalServletRequest(httpReq);

HttpSession sess = httpReq.getSession();
HttpSession sess1 = req.getSession();
String rl = (String) sess.getAttribute("userRole");
String r2 = (String) sess1.getAttribute("userRole");
System.out.println("portlet role--" + rl +"portlet role2--" + r2 );


As you see I am using both ways to get Httpsession but nothing helps me.
and sess i received the that i shows in my previous message attachment but how do i get in my code don't know.
Let me know if you have idea.


Thanks
Robin Thakur