I want to get content from an external server using Jetty and HttpClient class. Now I want to copy the obtained response as HttpServletResponse
and return to client (Browser). I've tried something but cannot succeed. I think I am not getting through with inner class.
Here is my code:
public void getContentsTo(String uri,HttpServletRequest request,final HttpServletResponse response){
HttpClient httpClient=new HttpClient();
httpClient.newRequest(uri).send( new org.eclipse.jetty.client.api.Response.CompleteListener() {
@Override
public void onComplete(Result result) {
response=(HttpServletResponse)result.getResponse();
};
});
The error is in assigning response
as:
The final local variable response cannot be assigned, since it is defined in an enclosing type
If I dont use final
for the parameter there is also a error as ,
Cannot refer to a non-final variable response inside an inner class defined in a different method
What is the cause?