@Context

[code lang=“java“]@GET
Produces(„application/xlm“)
public String getData(@Context HttpServletRequest request){
String ip = request.getRemoteAddr();
}[/code]

Die Annotation @Context kann folgende Objekte injizieren:

  • javax.ws.rs.core.HttpHeaders
  • javax.ws.rs.core.UriInfo
  • javax.ws.rs.core.Request
  • javax.servlet.HttpServletRequest
  • javax.servlet.HttpServletResponse
  • javax.servlet.ServletConfig
  • javax.servlet.ServletContext
  • javax.ws.rs.core.SecurityContext