Hello Friends,
In case you submitted need HttpServletRequest in your portlet, here is the code snippet.
HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
HttpServletRequest originalServletRequest= PortalUtil.getOriginalServletRequest(request);
This goes all the way from your custom code to PortalImpl and then PortletRequestImpl to get the request.
After getting request object it goes to find originalServletRequest.
This will be useful when you submitted your form or link without a proper portlet request or want to read a parameter from url.
Hope this helps.
In case you submitted need HttpServletRequest in your portlet, here is the code snippet.
HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
HttpServletRequest originalServletRequest= PortalUtil.getOriginalServletRequest(request);
This goes all the way from your custom code to PortalImpl and then PortletRequestImpl to get the request.
After getting request object it goes to find originalServletRequest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public HttpServletRequest getOriginalServletRequest( | |
HttpServletRequest request) { | |
HttpServletRequest originalRequest = request; | |
while (originalRequest.getClass().getName().startsWith( | |
"com.liferay.")) { | |
// Get original request so that portlets inside portlets render | |
// properly | |
originalRequest = (HttpServletRequest) | |
((HttpServletRequestWrapper)originalRequest).getRequest(); | |
} | |
return originalRequest; | |
} |
This will be useful when you submitted your form or link without a proper portlet request or want to read a parameter from url.
Hope this helps.