RESTful Web Services (JAX-RS) @FormParam Example

By using @FormParam annotation, RESTful web service would accept HTML form parameters sent by the client in the POST request and bind them to the method variables. Generally @FormParam will come into picture when client send the data in POST request, if its the GET request @QueryParam would be the best choice.

Let me give you an example on usage of @FormParam in the JAX-RS.

If you are new to RESTful web services, first go through ‘Jersey Hello World Example Using JAX-RS Specification‘ there you can learn each and every step to create a RESTful web service in eclipse, how to install maven and configuration settings related to JAX-RS.

Required Files

  • pom.xml and web.xml are similar to the previous article
  • Client.html



  • Right click on your project root folder > Run As > Run on Server
  • Eclipse will open http://localhost:2013/<projectRootFolder> with 404 Error by default, forget about that
  • Now open Client.html in your web browser, enter the details and click submit [ I have created this .html file to send input form parameters to our RESTful service, you no need to create & place this file in the project workspace, myself i have created client.html file in my desktop and open in Google chrome, and verified the output]
  • In Client.html, observe the URL in the from action [ line number 7 ]
  • Once you click on Submit, Client.html will POST the data to the restful service. From there REST service will retrieve those details by using @FormParam annotation.

RememberInput field names in Client.html [ line numbers 12,17 ] should match with @FormParam(“-“) parameters[ line numbers 16,17 ] in





You Might Also Like

  ::. About the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


2 Responses to “RESTful Web Services (JAX-RS) @FormParam Example”
  1. Rahul says:

    How to create client for this example

  2. bindu says:

    Hi i am a learner of web services.Firstly very well explained tutorial.I am building service with a pojo object having two fields user,email.I have same field in my client form which i am submitting.Here i am using @RequestBody so that it will map the fields on the fly.
    But i am facing an issue like ,
    WARNING: No message body reader has been found for request class Employee, ContentType : application/x-www-form-urlencoded.
    Jan 27, 2016 10:13:10 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse

    I didnt understand exactly where i am missing.Could you please help


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Hibernate Spring Struts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.