While using a Root- and SubResource in Jersey I annotated the RootResource like this to receive the form parameter param1.
@Path("some/path")
public SubResource doSomething(@FormParam("param1") String param1) {
...
}
Everything worked as I expected it to be, but, when the parameter is not given than jersey will return an internal error status code (500). In general I would say that this should be something like a bad request (400) or so.
What I then tried to do is, I added a MultivaluedMap<String, String> form into the parameter list (See: Jersey User Guide Example 2.19)
@Path("some/path")
public SubResource doSomething(MultivaluedMap<String, String> form) {
...
}
In this case I should be able to handle the form parameters for myself, but form did not get populated. Probably because of the missing @POST annotation.
My Question: Do you know a way, besides handling a HttpServletRequest which I find frustrating, so that I get my post parameters?
Thanks for your help…
I’m not entirely sure what you are trying to accomplish, but none of your examples seem valid to me. Since you are trying to pass processing onto a sub-resource you really should be dealing with the parameters there, instead of in the root resource. Heres an example:
EDIT
If you need access to form parameters in order to initialize your sub resource then access them via the HTTP servlet request: