Edit: The code below is for JAX-WS web services, while the question was about RESTful web services.
First: If you are using an EJB to implement the web service, then you will not be able to obtain the HTTP request object.
If you are not using an EJB, try this:
But how to run this code.. I am new into Rest web services and I only aware of RestEasy Web services.
I only know this kind of web services..
Please send me Complete code or yours and please also tell how to run this..
posted 8 years ago
Sorry, my mistake!
I missed that you are using REST web services.
The code I provided is for JAX-WS web services.
I will post a solution to your problem as soon as I have some more time.
I modified one of the examples enclosed with JBoss RESTEasy and here is an example of a method in a REST resource that can access the HttpServletRequest object related to the incoming request:
By annotating a method parameter, you assure yourself that the request object is obtained in connection to processing a request.
I had a case once where injection into an instance field resulted in one single dependency injection, which very soon became stale.
To see what kind of objects you can have injected into a resource class using the @Context annotation, see section 6.1 (if I remember correctly) of the JAX-RS specification.