views:

32

answers:

1

I’m trying to add some data to the http header that comes back from a RESTful web service call. Is it possible to use JAX-RS or something else to add data to the response header?

Example of my method:

@GET

@Path("getAssets")

public List<Asset> getAssets(@QueryParam("page") @DefaultValue("1") String  page,

                 @QueryParam("page_size") @DefaultValue(UNLIMITED) String  pageSize) throws Exception
{
  stuff…
}

Thanks for your help.

A: 

Using something such as Spring's MVC controller, you can easily get and set response headers as in the below example. A list of common headers can be found here Wikipedia - Common Headers

...

@RequestMapping(method = RequestMethod.GET) public String myGetMethod(@PathVariable string owner, @PathVariable string pet, HttpServletResponse response) {

response.setContentType("text/html"); response.setHeader("Content-disposition","Content-Disposition:attachment;filename=fufu.png");

} ...

Jason B-H