Show Topics
Hide Topics

JAX-RS @Context Example

 

JAX-RS provides the @Context annotation to inject a variety of resources in your RESTful services. Some of the most commonly injected components are HTTP headers, HTTP URI related information

  • HTTP headers
  • HTTP URI details
  • Security Context
  • Resource Context
  • Request
  • Configuration
  • Application
  • Providers

 

1.Create Dynamic web project in eclipse, convert that into Maven Project

 

2.Add Jersey jar files manually / through Maven by writing repo details in pom.xml

 

3.Create RESTFul webservice

 

 

4.Configure web.xml

 

5.Test Webservice directly by using URL / writing webservice client

  1. http://localhost:8080/JAXRS-Context-Example/rst/httpheaders
  2. http://localhost:8080/JAXRS-Context-Example/rst/uriinfo
  3. http://localhost:8080/JAXRS-Context-Example/rst/securitycontext

 

Download Example Code