开发者

Getting the URL of the Calling Application

When using JAX-RS is t开发者_高级运维here a way of getting information about who is calling the webservice? Can we get the ip or url of the calling application? If so how do you do it?

Thanks


The below should work on Weblogic (servlet container).

Once you get the HttpServletRequest via the @Context, you can access any of the methods of HttpServletRequest.

@GET
@Produces("text/plain")
public String showIP(@Context HttpServletRequest hsr) {
   return hsr.getRemoteAddr();
}

Note that there is no way to figure out what the real client IP address if there are any proxies in between.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜