Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JERSEY: How to retrieve the calling IP or URI using injection annotation?

Tags:

java

jersey

I have a REST- Server here using JERSEY. I must log the IP (better the DNS) of the calling client.

Can somebody point a direction which injection annotations to use ?

Searched "@Context", but could not find anything fitting.

Thanks Gerd

like image 534
user1226230 Avatar asked Feb 29 '12 12:02

user1226230


People also ask

How to inject an instance of uriinfo in the application?

An instance of UriInfo can be injected as field or method parameter using the @Context annotation. UriInfo provides access to application and request URI information. jersey-server 2.25.1: Jersey core server implementation.

How do I inject uriinfo in servlet?

An instance of UriInfo can be injected as field or method parameter using the @Context annotation. UriInfo provides access to application and request URI information. jersey-server 2.25.1: Jersey core server implementation. jersey-container-servlet 2.25.1: Jersey core Servlet 3.x implementation.

What is the use of uriinfo in Jersey?

UriInfo provides access to application and request URI information. jersey-server 2.25.1: Jersey core server implementation. jersey-container-servlet 2.25.1: Jersey core Servlet 3.x implementation. package com. logicbig. example; import javax. ws. rs. client.

Why is my SIP URI a numeric SIP url?

If the SIP request carries a user=phone tag, the SIP URI will always be interpreted as a numeric SIP URI. If no user=phone is present, the decision is based on the dial string interpretation setting in the calling device's (endpoint or trunk) SIP profile.


1 Answers

you could add @Context HttpServletRequest request as a parameter to your request handler method. And then get a hold of the client IP with request.getRemoteAddr()

like image 192
rompetroll Avatar answered Sep 21 '22 14:09

rompetroll