views:

46

answers:

1

I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist.

So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com

How can I do this ?

+2  A: 

You can add a UriInfo parameter to your operation. From there you can access the URL:

@POST
@Consumes({"application/xml", "application/json"})
public Response create(@Context UriInfo uriInfo, Customer customer) {
    ...
}
Blaise Doughan