I have web services developed using Jersey, and a service take as parameter a Java Bean annotated with @QueryParam annotations on fields. It works fine when the service is invoked directly via its URL. Now I wish to call that service programatically from another piece of code (a JSP in the same WAR, say). I wish to have the bean parameter filled in with the query parameters of my current request, basically doing myself what Jersey does for me automatically when I call the service URL.
I want really to be able to take the request parameters and inject them into the relevant bean fields. I know I could do that myself with BeanUtils and reading the annotations myself, but surely there is an easier way?
Example code: My service defines this method
@GET
public Response generate(@BeanParam Options options){...}
And Options is a Bean that has fields like
@QueryParam("format")
private String format="pdf";
I want to be able to write something like:
Options myoptions=new Options();
???.inject(myoptions,request);
in my JSP.
Does it make sense?