cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain client IP address using web script

tonyc
Champ in-the-making
Champ in-the-making
Is there a way to obtain the clients IP address using an MVC web script?
5 REPLIES 5

rogier_oudshoor
Champ in-the-making
Champ in-the-making
Sure, but you have to use Java as your controller. Alfresco's WebScriptRequest wraps around a standard Java HttpServletRequest, which holds the IP adress of the requester.

scouil
Star Contributor
Star Contributor
Hello,

I was wondering if this changed or not.
With my WebScriptRequest I couldn't find a way to get the IP address or to retrieve a HttpServletRequest Object where I could apply getRemoteAddr().

And I was wandering, is the java-backed webscript the only way to do it or could I just expose some java object to javascript that would enable me to get the client IP?

Thanks,

scouil
Star Contributor
Star Contributor
Got it, all we need is a cast:


if (req instanceof WebScriptServletRequest) {
   HttpServletRequest r = ((WebScriptServletRequest) req).getHttpServletRequest();
   String sourceIp = r.getRemoteAddr();
}

gmahesh
Champ in-the-making
Champ in-the-making
How to track IP address of Client while auditing in alfresco?

g_rathod
Star Contributor
Star Contributor
This is not working for alfresco 4.2x.
Any idea what is working solution ?