views:

45

answers:

1

Hi. I try to access a local file from a RESTFul service. Is there any way to get the real path of the running service ? (as we can do in a servlet)

Server : glassfish 3.0.1 IDE : Eclipse Helios

Thx

+2  A: 

Hi Bigmac,

Which framework you are using for REST web service?
You can get the real path in Jersey by following way:

@Context ServletContext context //you can specify in your method argument
String realPath = context.getRealPath("/");

Think will help you.

Jprogyog
Thanks. That works just fine. I'm using Jersey but, for some reason, I didn't think I could inject the ServletContext (I was stuck with UriInfo, Request and HttpHeaders). I guess it was a stupid question...Not enough reading. Thanks again.
Bigmac
I am glad that it helped you. Can you please accept the answer. Will help other guys too in future. Thanks.
Jprogyog