Saturday, November 9, 2013

How to get HttpServletRequest and HttpServletResponse from JSF Portlet context in Liferay

// get PortletRequest from JSF Portlet context
PortletRequest portletRequest = (PortletRequest) FacesContext
.getCurrentInstance().getExternalContext().getRequest();

// convert the PortletRequest object to HttpServletRequest object
HttpServletRequest servletRequest = PortalUtil
.getHttpServletRequest(portletRequest);



// get PortletResponse from JSF Portlet context
PortletResponse portletResponse = (PortletResponse) FacesContext
.getCurrentInstance().getExternalContext().getResponse();

// convert PortletResponse object to HttpServletResponse object
HttpServletResponse servletResponse = PortalUtil
.getHttpServletResponse(portletResponse);

LinkWithin

Related Posts Plugin for WordPress, Blogger...