Bigmac
Bigmac

Reputation: 51

How can I access local files from a RESTFul web service

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

Upvotes: 0

Views: 3687

Answers (2)

user1907542
user1907542

Reputation: 1

Code:

@Context ServletContext context;//you can specify this above method as annotation

String realPath = context.getRealPath("/");

Upvotes: 0

jaxb
jaxb

Reputation: 2077

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.

Upvotes: 6

Related Questions