title: Return custom object AND controlling response code in JAX-RS
body: <p>I'm using JAX-RS in my web application to return my own object.
  I want to keep doing it, but I want to set the HTTP response code (e.g. 401 for unauthorized, etc.).
  From the information I've found it seems like I have to return the type Response and not my custom object.
  Is that correct?</p>
  
  <p>My current code (simplified) - when <strong>MyReponse</strong> is an object that Jaxb knows how to deal with:</p>
  
  <pre><code>@POST
  @Produces({MediaType.APPLICATION_XML , MediaType.APPLICATION_JSON})
  public MyResponse RegisterUser (
          @FormParam("userName") String userName,
          @FormParam("password") String password) {
      // add user logic
      return new MyResponse(....&lt;params to ctor...);
    }
  </code></pre>