Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Component(
- immediate = true,
- property = {
- "com.liferay.portlet.display-category=IPC Sender",
- "com.liferay.portlet.instanceable=true",
- "javax.portlet.display-name=IPC_Sender Portlet",
- "javax.portlet.init-param.template-path=/",
- "javax.portlet.init-param.view-template=/view.jsp",
- "com.liferay.portlet.private-session-attributes=false",
- "javax.portlet.resource-bundle=content.Language",
- "javax.portlet.security-role-ref=power-user,user"
- },
- service = Portlet.class
- )
- public class ipcsenderPortlet extends MVCPortlet {
- public void hello(ActionRequest actionRequest,
- ActionResponse actionResponse) throws Exception
- {
- //Trying to set HttpSession but its also getting null while retrieving
- HttpServletRequest httpreq = PortalUtil.getHttpServletRequest(actionRequest);
- HttpSession session = httpreq.getSession(true);
- session.setAttribute("transfer", "content");
- ////Trying to set Portletsession but its also getting null while retrieving
- PortletSession portletsession = actionRequest.getPortletSession();
- portletsession.setAttribute("sendvalue","abcde",
- PortletSession.APPLICATION_SCOPE);
- }
- }
- @Component(
- immediate = true,
- property = {
- "com.liferay.portlet.display-category=IPC Receiver",
- "com.liferay.portlet.instanceable=true",
- "javax.portlet.display-name=IPC_Receiver Portlet",
- "javax.portlet.init-param.template-path=/",
- "javax.portlet.init-param.view-template=/view.jsp",
- "javax.portlet.resource-bundle=content.Language",
- "com.liferay.portlet.private-session-attributes=false",
- "javax.portlet.security-role-ref=power-user,user"
- },
- service = Portlet.class
- )
- public class ipcreceiverPortlet extends MVCPortlet
- {
- public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException
- {
- //HttpSession
- HttpServletRequest httpreq = PortalUtil.getHttpServletRequest(renderRequest);
- HttpSession session = httpreq.getSession();
- String name = (String)session.getAttribute("transfer");
- System.out.println("Session value through HttpSession:"+name);
- //PortletSession
- PortletSession portletsession = renderRequest.getPortletSession();
- String userName = (String) portletsession.getAttribute("sendvalue",PortletSession.APPLICATION_SCOPE);
- System.out.println("nSession value through PortletSession:"+userName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement