Obtain HttpServletRequest object in WebService

E

Eric Chan

Hi,

I am implementing a webservice and I would like to know the IP address
of the caller. I believe the only class that contains this
information is in the Request, request.getHeader("USER-AGENT");

Does anyone know what object and method I can use to obtain the
HttpServletRequest when my web service is called? Or am I on the
right track?

Thanks a million for any help.

Eric
 
A

Andy Fish

Eric Chan said:
Hi,

I am implementing a webservice and I would like to know the IP address
of the caller. I believe the only class that contains this
information is in the Request, request.getHeader("USER-AGENT");

Does anyone know what object and method I can use to obtain the
HttpServletRequest when my web service is called? Or am I on the
right track?

how about ServletRequest.getRemoteAddr()

this will tell you what's on the other end of the socket. As with all HTTP
things though, it won't help if the request is going through a proxy or NAT.
There is no way to reliably tell the ultimate source of the request

I wouldn't have thought you can get any useful information from the
user-agent header

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top