2

Anyone know how to get content of httprequest in REST webservice using java?

thanks

1
  • what have you used to implement webservice? Commented Apr 21, 2011 at 5:38

2 Answers 2

3

You can inject context about the individual requests. As an example, the code snippet below shows how the HTTP request headers can be injected.

@GET  
@Produces{"text/plain"}  
public String listHeaderNames(@Context HttpHeaders headers) {  
  StringBuilder buf = new StringBuilder();  
  for (String header: headers.getRequestHeaders().keySet()) {  
    buf.append(header);  
    buf.append("\n");  
  }  
  return buf.toString();  
}

See the relevant part of the JAX-RS 1.1 specification for more information.

Sign up to request clarification or add additional context in comments.

Comments

1

Look at Restlet

// Create the client resource  
ClientResource resource = new ClientResource("http://www.restlet.org");  

// Write the response entity on the console
resource.get().write(System.out);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.