users@jsr311.java.net

current update of spec of JSR 311: status code of resource methods

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Tue, 29 Jan 2008 12:23:36 +0100

Hello,

I've a question to the update of the JAX-RS specification:

Why must the status code be 202 (Accpeted), if a resource method returns
any other than void or Reponse? I think this change throw away the
advantage of the possibility to return an object that not is a response.
I think it is useful to have different status codes for different HTTP
methods:

    * For GET (and HEAD) I think 200 (OK) is the better status code,
      because that is the typical status code for this HTTP methods.
    * For POST I think it is better to return status code 201 (Created)
      by default. If the resource method returns an URI, this could be
      mapped to the location header.
          o To ease the development of web application you have the
            possibility to specify to return 303 (see other) when the
            request was send by a browser and an URI was returned
            (redirect after post pattern). To identify that the request
            was send by a browser I suggest @ProduceMime("text/html") on
            the resource method. Perhaps it is useful to require also
            (or perhaps only)
            @ConsumeMime("application/x-www-form-urlencoded").
    * For DELETE and PUT I suggest 200 (OK) if the resource method
      returned an object as entity or 204 (no content) if null was
      returned, like the case void.

Of course this is all possible by use the static methods of Response,
but the intention of the JSR 311 specification is to make this things as
easy as possible.
On the other hand the specification will grow, but I think it's not a
big thing here.

In general the clarification was good.

BTW: I think it is good to add a comment to Response.seeOther(URI) that
this method should be used to use the redirect after post pattern.

best regards
  Stephan Koops