I'm writing a RESTful service app in Java EE 6. I've encountered a difficulty along defining HTTP GET service method which uses the @FormParam annotation.
Technologies that I use:
- Eclipse EE Kepler IDE
- JDK v7
- Glassfish 3 (based on Java 6)
- Jersey (part of Glassfish)
Java:
@GET
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
@Path("/getFromForm")
public String getFromForm(@FormParam("input") String input){
log.log(Level.INFO, "Invoked getFromForm");
String html = "<html> <body>"
+"<center><h1> "+input+"</h1></center>"
+"</body></html>";
return html;
}
JSP:
<form action="/RESTfulServiceDrill/rest/v6/html/getFromForm" method="get"
enctype="application/x-www-form-urlencoded">
<label> Add message: </label>
<input type="text" name="input"/>
<input type="submit" value="OK"/>
<input type="reset" value="clear"/>
</form>
Exception:
java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
Any ideas what the culprit is?