Showing posts with label PortletRequest and HttpServletRequest. Show all posts
Showing posts with label PortletRequest and HttpServletRequest. Show all posts

How to get HttpServletRequest and HttpServletResponse from portlet request

There are some scenario when you want to get httpServletRequest or httpServletReponse from portletRequest.

IBM provides an utility class which gives you what you are looking for.

Yes, there is a PortletUtil class available in the com.ibm.ws.portletcontainer.portlet package, through which you can directly get httpServletRequest, httpServletResponse, ServletContext and many  more servlet object you want.


Code to get HttpServletRequest from  portletRequest/renderRequest/actionRequest.

HttpServletRequest httpServletRequest =  PortletUtils.getHttpServletRequest(renderRequest);

There are couple of utility methods available in PortletUtil which  gives you ServletContext, ServletConfig, PortletWindow, PortletApplicationDefinition etc.