Search code examples
jspjerseyjax-rs

Accessing javax.ws.rs.core.Response header in a JSP


Given the following in a JAX-RS resource using Jersey:

import javax.ws.rs.core.Response;
...
Map<String, String> map = new HashMap<String, String>();
map.put("myAttribute", "value");
return Response.ok(new Viewable("myJsp.jsp", map))
    .build();

What is the correct way to access myAttribute from the jsp? Have tried this, but it returns null:

console.log("<%= response.getHeader("myAttribute") %>");

Note that the JSP page is included in a parent page using <jsp:include>.

Thanks


Solution

  • According the Jersey MVC documentation, you could access it with:

    console.log("${model.myAttribute}");
    

    or

    console.log("${it.myAttribute}");