title: Create Response with Location header in JAX-RS
body: <p>I have classes auto-generated in NetBeans with RESTful template from entities, with CRUD functions (annotated with POST, GET, PUT, DELETE). I have a problem with <em>create</em> method, which after inserting an entity from the frontend, I would like <em>create</em> to update a response so that my view will automatically (or asynchronously, if that's the right term) reflect the added entity.</p>
  
  <p>I came across this (example) line of code but written in C# (of which I know nothing about):</p>
  
  <pre><code>HttpContext.Current.Response.AddHeader("Location", "api/tasks" +value.Id);
  </code></pre>
  
  <p>Using JAX-RS in Java, is there anyway to get the current HttpContext just like in C# and to manipulate the header?</p>
  
  <p>The closest I came about is </p>
  
  <pre><code>Response.ok(entity).header("Location", "api/tasks" + value.Id);
  </code></pre>
  
  <p>and this one certainly is not working. It seems I need to get the current HttpContext before building the Response. </p>
  
  <p>Thanks for your help.</p>