Overwrite HTTP method with JAX-RS
Asked Answered
F

3

1

Today's browsers (or HTML < 5) only support HTTP GET and POST, but to communicate RESTful one need PUT and DELETE too. If the workaround should not be to use Ajax, something like a hidden form field is required to overwrite the actual HTTP method.

Rails uses the following trick:

<input name="_method" type="hidden" value="put" />

Is there a possibility to do something similar with JAX-RS?

Foozle answered 14/5, 2010 at 8:59 Comment(0)
S
2

Not strictly a JAX-RS solution but spring 3.0 comes with a HiddenHttpMethodFilter that implements exactly the trick that rails does, defaults to the same _method parameter.

Note that you don't need to be using all of spring to use this filter, you can just configure it in your web.xml and ignore the rest of spring.

Shabuoth answered 11/5, 2011 at 10:50 Comment(0)
T
1

Jersey also has something similar, filtering a header field though. Documentation can be found here

Tanyatanzania answered 11/5, 2011 at 11:0 Comment(0)
K
0

To quote Roy Fielding:

In any case, there are plenty of RESTful services that do nothing but GET and POST. The key is how those methods are used, not what methods are used. To give a specific example, what makes a wiki more or less RESTful is almost always determined by how it (ab)uses GET and sessions -- whether it uses PUT or POST for editing pages is sugar topping in comparison.

Emphasis is mine, taken from this post http://tech.groups.yahoo.com/group/rest-discuss/message/10746

Kibitz answered 14/5, 2010 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.