How can i access client details like IP,Browser etc in a web service in java?
A:
Information related to Browser would be available in the HTTP headers like : content type, version etc. If a web service were able to get the IP address of it clients, the security would have been heavily comprised. IP address can be never accessed until the client sends it as a param to your call.
Cshah
2009-09-09 09:31:42
Why would the security be compromised? The server does always know the IP address of the client. Otherwise, it wouldn't know where to send the response to a request
janko
2009-09-09 09:35:00
No, the server only knows the IP address to respond to, which may be the address of a proxy server or NAT device. This may not be an IP address of the client.
John Saunders
2009-09-09 09:41:09
@janko, When you connect to a server in a internet, the server only knows the next hop address and not the ip address of the client. And if you are behind a proxy then at max the server can know the proxy ip but not the actual client ip which sits behind the proxy
Cshah
2009-09-09 09:46:35
+1
A:
String ip = request.getRemoteAddress();
String browser = request.getHeader("User-Agent");
ZZ Coder
2009-09-09 09:48:42
+1
A:
if you are using axis or Jax Rpc, then you can this to get the IP Address and Browser, This has to be done on the server side stub.
HttpServletRequest httpReq = (HttpServletRequest) MessageContext.getCurrentContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
String ip = httpReq.getRemoteAddr();
String browser = httpReq.getHeader("User-Agent");
shivaspk
2009-09-09 11:17:31