Hi,
im using spring 3.
i have a special requirement in my project. I need to send(forward) HTTP post request from one of my spring controllers to a external servlet,(servlet only processes post-requests) and returns its result, a jsp page.
is it possible to send/forward a post request from a spring controller and show the result (jsp) from this servlet ?
i have tried to create and send the http post from my spring controller with apache-httpcomponents .
It sends the request, but the problem is that im forwarded to the response from my spring controller, and not the servlet jsp. Is it possible to send the http-post to the servlet, and show its jsp-result ?
Here is the code i tried:
Code:@RequestMapping(value = "/runmytestmethod/{id}", method = RequestMethod.GET) public void getRunReportPage(@PathVariable Integer id, Model model,HttpSession session,HttpServletRequest request) { DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://targethost/processfurther"); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); HttpResponse response2 = httpclient.execute(httpPost); try { System.out.println(response2.getStatusLine()); HttpEntity entity2 = response2.getEntity(); // do something useful with the response body // and ensure it is fully consumed EntityUtils.consume(entity2); } finally { httpPost.releaseConnection(); } }
all help appreciated...thanks.


Reply With Quote
