You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Guyatt <pg...@telesoft-technologies.com> on 2003/09/12 17:29:29 UTC

Obtaining client connection

Hi There,

	I am not too sure if you are actually able to do this but I have a need to
get the IP address/hostname of the client that has accessed a page in our
web application.

This is mainly for security/auditing purposes, however I really need to get
the client Socket connection and not the ip address given in the attributes
of the HTTP header.

Is there any way of obtaining a handle on the client socket that has
connected to the server.

Any help on this matter would be greatly appreciated.

Currently we are using Tomcat version 4.1.18

Many Thanks

Pete Guyatt


Re: Obtaining client connection

Posted by Bill Barker <wb...@wilshire.com>.
It sounds like all you want is
request.getRemoteAddr()/request.getRemoteHost().  These give you the
IP/DNS-name of the client's box.  All of this is taken from the Socket
(since there really isn't any other way to get at it).

If you need to get the IP on your machine that they connected to, then you
can't.  request.getServerName() reports what was sent in the Headers.

"Peter Guyatt" <pg...@telesoft-technologies.com> wrote in message
news:IIEDKFJNELHIHEMPNDGKAEDOCGAA.pguyatt@telesoft-technologies.com...
> Hi There,
>
> I am not too sure if you are actually able to do this but I have a need to
> get the IP address/hostname of the client that has accessed a page in our
> web application.
>
> This is mainly for security/auditing purposes, however I really need to
get
> the client Socket connection and not the ip address given in the
attributes
> of the HTTP header.
>
> Is there any way of obtaining a handle on the client socket that has
> connected to the server.
>
> Any help on this matter would be greatly appreciated.
>
> Currently we are using Tomcat version 4.1.18
>
> Many Thanks
>
> Pete Guyatt