-
How to get session attribute in velocity template in liferay
over 9 years ago
-
over 8 years ago
Hi Please check liferay-portlet.xml as below :
<portlet> <portlet-name>dashboard</portlet-name> <icon>/icon.png</icon> <private-session-attributes>false</private-session-attributes> <header-portlet-css>/css/main.css</header-portlet-css> <footer-portlet-javascript> /js/main.js </footer-portlet-javascript> <css-class-wrapper>dashboard-portlet</css-class-wrapper> <add-default-resource>true</add-default-resource> </portlet>
Private session attribute should be false.
<private-session-attributes>false</private-session-attributes>
-
-
over 8 years ago
Hi can you please tell me Fetch the session object set in liferay theme java method into portlet doView() method
i have a below method in theme:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)throws IOException, ServletException { ((HttpServletRequest) request).getSession().setAttribute("test", "abc"); }
i am trying to fetch above session object in doView method of portlet.
HttpSession httpSession =PortalUtil.getHttpServletRequest(renderRequest).getSession(); System.out.println("httpSession obj"+(String)httpSession.getAttribute("test"));
i even tried using as below :
HttpServletRequest request1 =PortalUtil.getHttpServletRequest(renderRequest); HttpServletRequest originalRequest = PortalUtil.getOriginalServletRequest(request1); HttpSession httpsession = originalRequest.getSession(); System.out.println("httpSession ==> " + httpsession);//session object gets printed System.out.println("test "+httpsession.getAttribute("test"));//null
i get the null value when i try to fetch from doview method. Can anyone please suggest how to fetch the value from theme to portal
-
2 Comment(s)