<div dir="ltr" style="text-align: justify;" trbidi="on">In this tutorial we will discuss about <i><b>@FormParam</b></i>, In <i><b>JAX-RS</b></i>, you can use <i><b>@FormParam</b></i> annotation to bind HTML form parameters value to a Java method. The following example show you how to do it :<br />
<b>1. HTML Form</b><br />
See a simple HTML form with &#8220;post&#8221; method.</p>
<pre class="highlight" name="code"><;html>; 
<;body>; 
 <;h1>;JAX-RS @FormQuery Testing<;/h1>; 
 
 <;form action="doj/employee/add" method="post">; 
 <;p>; 
 Employee Name : <;input type="text" name="empname" />; 
 <;/p>; 
 <;p>; 
 Employee Age : <;input type="text" name="empage" />; 
 <;/p>; 
 <;input type="submit" value="Add Employee" />; 
 <;/form>; 
 
<;/body>; 
<;/html>; 
</pre>
<div align='center' id="ads-id"></div>
<p><b>2. <i>@FormParam</i> Example</b><br />
<b><br />
</b> <b>Example to use <i>@FormParam</i> to get above HTML form parameter values.</b></p>
<pre class="highlight" name="code">package com.dineshonjava.ws.rest; 
 
import java.util.List; 
 
import javax.ws.rs.DefaultValue; 
import javax.ws.rs.FormParam; 
import javax.ws.rs.GET; 
import javax.ws.rs.MatrixParam; 
import javax.ws.rs.POST; 
import javax.ws.rs.Path; 
import javax.ws.rs.PathParam; 
import javax.ws.rs.QueryParam; 
import javax.ws.rs.core.Context; 
import javax.ws.rs.core.Response; 
import javax.ws.rs.core.UriInfo; 
 
/** 
 * @author Dinesh Rajput 
 * 
 */ 
@Path("/employee") 
public class EmployeeController { 
 
 
 @POST 
 @Path("/add") 
 public Response addEmployee( 
 @FormParam("empname") String empname, 
 @FormParam("empage") int empage) { 
 
 return Response.status(200) 
 .entity("addEmployee is called, employee name : " + empname + ", employee age : " + empage) 
 .build(); 
 
 } 
} 
 
</pre>
<p>
 <b>3. Now access the following urls.</b><br />
<b><br />
</b> <b>http://localhost:8181/sdnext/userform.html</b></p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://dineshonjava.com/wp-content/uploads/2013/06/userform.png"/></div>
<p>
<b>When &#8220;Add Employee&#8221; button is clicked, it will redirect to URL :</b><br />
<i><b> ;http://localhost:8181/sdnext/doj/employee/add</b></i></p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://dineshonjava.com/wp-content/uploads/2013/06/userform2.png"/></div>
<p>
<b>Download SourceCode</b><br />
<b><a href="https://sites.google.com/a/dineshonjava.com/dineshonjava/dineshonjava/JAX-RS%20%40FormParam%20example.zip?attredirects=0&;d=1" target="_blank">JAX-RS @FormParam example.zip</a></b></p>
<p>
<i><b>References</b></i><br />
1.<b> <i><a href="http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html" target="_blank">JAVA REST Web Services</a></i></b><br />
2. <i><b><a href="http://en.wikipedia.org/wiki/Web_service" target="_blank">Wikipedia for REST Web Service</a></b></i></p>
<p> ; </p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/jax-rs-matrixparam-example/">Previous </a><;<; ; ; || <a href="https://dineshonjava.com/jax-rs-web-service-tutorial/">Index </a>||  ; >;>;<a href="https://dineshonjava.com/get-http-header-in-jax-rs/">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jax-rs-matrixparam-example/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/get-http-header-in-jax-rs/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '420'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…