Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Rupesh Chotai
How to get user id from different webapp (servlet)
May 10, 2013 6:14 AM
Answer

Rupesh Chotai

Rank: Regular Member

Posts: 163

Join Date: March 23, 2011

Recent Posts

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.
1
2long userId = PortalUtil.getUserId(httpServletRequest);


Is there a way I can handle this?
Apoorva Prakash
RE: How to get user id from different webapp (servlet)
May 10, 2013 2:57 PM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

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.
1long userId = PortalUtil.getUserId(httpServletRequest);


Is there a way I can handle this?


Hey Rupesh,

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

HTH.

-Apoorva Prakash