Hello Servlet Spec community,
Is there any reason why getting parameters shouldn't work for PUT requests?
Even latest, Servlet 3.1 public review spec, has following:
{quote}
3.1.1 When Parameters Are Available
The following are the conditions that must be met before post form data
will be
populated to the parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is POST.
3. The content type is application/x-www-form-urlencoded.
4. The servlet has made an initial call of any of the getParameter family
of methods
on the request object.
If the conditions are not met and the post form data is not included in the
parameter
set, the post data must still be available to the servlet via the request
object’s input
stream. If the conditions are met, post form data will no longer be
available for
reading directly from the request object’s input stream.
{quote}
Other frameworks like Jersey (see
http://java.net/jira/browse/JERSEY-1200 )
and Spring framework (see
https://jira.springsource.org/browse/SPR-5628 )
support getting parameters from PUT requests.
Some of the servlet containers, like Jetty (see
http://jira.codehaus.org/browse/JETTY-655 ) wrongly already support getting
parameters from PUT requests.
But, IMO this is dangerous, and should be covered by Servlet spec (e.g.
imagine developing and testing something on Jetty, and then having it run
on production just to discover the discrepancy).
So, if there are no valid reasons why not to support getting parameters
from PUT requests, I propose to change that 3.1.1 paragraph in spec into:
{quote}
3.1.1 When Parameters Are Available
The following are the conditions that must be met before form data will be
populated to the parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is POST or PUT.
3. The content type is application/x-www-form-urlencoded.
4. The servlet has made an initial call of any of the getParameter family
of methods
on the request object.
If the conditions are not met and the form data is not included in the
parameter
set, the data must still be available to the servlet via the request
object’s input
stream. If the conditions are met, form data will no longer be available for
reading directly from the request object’s input stream.
{quote}
Kind regards,
Stevo Slavic.