In JAX-RS, you can use @FormParam annotation to bind HTML form parameters value to a Java method. The following example show you how to do it :

1. HTML Form

See a simple HTML form with “post” method.

	<h1>JAX-RS @FormQuery Testing</h1>

	<form action="rest/user/add" method="post">
			Name : <input type="text" name="name" />
			Age : <input type="text" name="age" />
		<input type="submit" value="Add User" />


2. @FormParam Example

Example to use @FormParam to get above HTML form parameter values.


public class UserService {

	public Response addUser(
		@FormParam("name") String name,
		@FormParam("age") int age) {

		return Response.status(200)
			.entity("addUser is called, name : " + name + ", age : " + age)



3. Demo

Access HTML Page. URL : http://localhost:8080/RESTfulExample/UserForm.html

demo html page

When “add user” button is clicked, it will redirect to URL : http://localhost:8080/RESTfulExample/rest/user/add

demo jax-rs result

and display the following output :

addUser is called, name : mkyong 123, age : 12

Download Source Code

Download it – (6 KB)


  1. JAX-RS @FormParam JavaDoc