掲示板
httpservletrequest in icefaces portlet
13年前 に Jigar N Gajjar によって更新されました。
httpservletrequest in icefaces portlet
Junior Member 投稿: 71 参加年月日: 09/12/25 最新の投稿
Hi,
i want to get httpservletrequest from the icefaces portlet, i am using
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
but it is giving classcastexcpetion as it is not able to cast in httpservletrequest
Thanks
Jigar Gajjar
i want to get httpservletrequest from the icefaces portlet, i am using
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
but it is giving classcastexcpetion as it is not able to cast in httpservletrequest
Thanks
Jigar Gajjar
11年前 に Jagat Pandya によって更新されました。
RE: httpservletrequest in icefaces portlet
New Member 投稿: 7 参加年月日: 10/11/22 最新の投稿
HttpServletRequest httpRequest = (HttpServletRequest) (FacesContext
.getCurrentInstance().getExternalContext().getRequestMap()
.get("com.liferay.portal.kernel.servlet.PortletServletRequest"));
.getCurrentInstance().getExternalContext().getRequestMap()
.get("com.liferay.portal.kernel.servlet.PortletServletRequest"));
11年前 に David H Nebinger によって更新されました。
RE: httpservletrequest in icefaces portlet
Liferay Legend 投稿: 14918 参加年月日: 06/09/02 最新の投稿Jagat Pandya:
HttpServletRequest httpRequest = (HttpServletRequest) (FacesContext
.getCurrentInstance().getExternalContext().getRequestMap()
.get("com.liferay.portal.kernel.servlet.PortletServletRequest"));
Wrong wrong wrong.
First, the OP's code fails because:
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
The request instance is a PortletRequest, not an HttpServletRequest. Cast it to a PortletRequest and you're fine.
Second, if you need the original HttpServletRequest (which I highly doubt because no one in the portlet world typically needs this request), you use the com.liferay.portal.util.PortalUtil.getHttpServletRequest(PortletRequest) to access it.
Do not attempt Jagat's 'back door' access because it may break in the future, where the API will be maintained.
11年前 に Neil Griffin によって更新されました。
moved thread to Liferay Faces forum
Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
moved thread to Liferay Faces forum