Reputation: 62596
Using Jersey, I want to be able to have a GET request, that would result in the server code making an HTTP request on itself at another resource that returns a json object. I know Jersey has both client and server apis that are separate, is there some way to combine the two?
@Path("/helloworld")
public class GetData {
@GET
public String getResource() throws IOException {
String result;
//Insert code to make an http request to localhost/someobject.json and store it in a variable
return result;
}
}
Upvotes: 1
Views: 395
Reputation: 13097
There is no reason why you can't just use the client and server Jersey in the same code, just like it were any other code. However, chaining HTTP requests like sounds like it might not be the best idea. Are you sure this is what you want to be doing?
Upvotes: 1