留言板

How to get user id from different webapp (servlet)

Rupesh Chotai,修改在10 年前。

How to get user id from different webapp (servlet)

Regular Member 帖子: 163 加入日期: 11-3-23 最近的帖子
Hi,
We have another webapp (servlet) running in parallel with Liferay portal on the same tomcat. From view.jsp of portlet, an Ajax request has been made to the servlet in this webapp. How to retrieve the user id/user details of logged in liferay portal user in that another webapp (servlet)?

I tried with below code snippet in doGet() method of servlet, but it always return userId as zero.

long userId = PortalUtil.getUserId(httpServletRequest);


Is there a way I can handle this?
thumbnail
Apoorva Prakash,修改在10 年前。

RE: How to get user id from different webapp (servlet)

Liferay Master 帖子: 658 加入日期: 10-6-15 最近的帖子
Rupesh Chotai:
Hi,
We have another webapp (servlet) running in parallel with Liferay portal on the same tomcat. From view.jsp of portlet, an Ajax request has been made to the servlet in this webapp. How to retrieve the user id/user details of logged in liferay portal user in that another webapp (servlet)?

I tried with below code snippet in doGet() method of servlet, but it always return userId as zero.
long userId = PortalUtil.getUserId(httpServletRequest);


Is there a way I can handle this?


Hey Rupesh,

Try the following, it may work:
httpServletRequest.getRemoteUser()

HTH.

-Apoorva Prakash