Over a million developers have joined DZone.

RESTEasy's @Form

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

@Form is one of RESTEasy's best features. It encapsulates any set of inputs - path params, query params, form params, headers, cookies and PUT/POST body. NOTE: @Form does not ONLY encapsulate HTML Form input, although it can as described in my article about integrating RESTEasy with Spring MVC

Here's how it's used in an application:

public class MyForm {

   private int stuff;

   private String header;

   public void setFoo(String foo) {...}

public void post(@Form MyForm form) {...}


I've had HTTP input reuse in every big HTTP application that I've built in 3 organizations. 2 of the organizations used RESTEasy, and the results were a lot cleaner than the 3rd org with the use of @Form than with some of the "reuse hacks" I've had to do when using Jersey. Here are some other benefits I've had from @Form:

  • Input processing Logic: custom conversion, multi-variable processing (if param X isn't there, then param Y should be used in conjunction with header Z).
  • Content based security
  • Integration with JSR 303/Bean Validation (you can't use it unless you have a bean...). The processing happened via a RESETEasy interceptor. IMHO, the end result was elegant and simple.

I really hope that this feature gets into JAX-RS 2.0, although I think that the name would have to be more expressive than @Form.


From http://www.jroller.com/Solomon/entry/resteasy_s_form

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}