I am doing some thing like that:
@Override
public ContainerRequest filter(ContainerRequest request)
{
System.out.println("IP ====>>>"+request.getRequestHeader("x-forwarded-for"));
}
But I am getting Null
.
This version of JERSEY don't have request.getRemoteAddr()
method.
How can I get IP in this version of JERSEY ??
As I see not only x-forwarded-for can contains IP. Try to use other header parameters. Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful? . ContainerRequest has getRequestHeaders() which returns all headers values. https://jersey.java.net/apidocs/1.5/jersey/com/sun/jersey/spi/container/ContainerRequest.html#getRequestHeaders() You can debug and try to find needed attribute.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.