Java Reference
In-Depth Information
Click here to view code image
<FORM action="http://example.com/employees/" method="post">
<p>
<fieldset>
Employee name: <INPUT type="text" name="empname" tabindex="1">
Employee address: <INPUT type="text" name="empaddress" tabindex="2">
Manager name: <INPUT type="text" name="managername" tabindex="3">
</fieldset>
</p>
</FORM>
Use the following code snippet to extract the manager name from this HTML form:
Click here to view code image
@POST
@Consumes("application/x-www-form-urlencoded")
public void post(@FormParam("managername") String managername) {
// Store the value
...
}
To obtain a map of form parameter names to values, use a code snippet like the following:
Click here to view code image
@POST
@Consumes("application/x-www-form-urlencoded")
public void post(MultivaluedMap<String. String> formParams) {
// Store the message
}
Extracting the Java Type of a Request or Response
The javax.ws.rs.core.Context annotation retrieves the Java types related to a
request or response.
The javax.ws.rs.core.UriInfo interface provides information about the com-
ponents of a request URI. The following code snippet shows how to obtain a map of query
and path parameter names to values:
Click here to view code image
@GET
public String getParams(@Context UriInfo ui) {
MultivaluedMap<String, String> queryParams =
ui.getQueryParameters();
Search WWH ::




Custom Search