Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #20291

POSTing to a servlet

Newsgroups comp.lang.java.programmer
Date 2012-12-13 05:59 -0800
Message-ID <e3d17f12-5b5f-4655-a596-402d66bcbf82@googlegroups.com> (permalink)
Subject POSTing to a servlet
From RVic <rvince99@hotmail.com>

Show all headers | View raw


I have a JUnit test that tests a servlet. The code is straightforward:

HttpClient httpClient = new DefaultHttpClient();
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
HttpPost httpPost = new HttpPost("http://myaerver.com:8080/servlets/json");
addParameter(nvps, "query", "engagementByFacility");
addParameter(nvps, "surveyId", 681150);		
httpPost.setEntity(new UrlEncodedFormEntity(nvps));			
ResponseHandler<String> responseHandler = new BasicResponseHandler();		
String responseBody = httpClient.execute(httpPost, responseHandler);

On this last line however, httpClient.execute(), things fail and I am at an utter loss as to why. The URL is good. Examination of the stack shows:

org.apache.http.client.HttpResponseException: Moved Temporarily
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:68)
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1035)
at ees.cmn.web.servlet.JSONServletTest.testFindOrgs(JSONServletTest.java:75)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)


"Moved Temporarily?" What in the world might be going on here? TIA

RVince

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar | Unroll thread


Thread

POSTing to a servlet RVic <rvince99@hotmail.com> - 2012-12-13 05:59 -0800
  Re: POSTing to a servlet Arne Vajhøj <arne@vajhoej.dk> - 2012-12-13 19:50 -0500
  Re: POSTing to a servlet Roedy Green <see_website@mindprod.com.invalid> - 2012-12-17 02:46 -0800
  Re: POSTing to a servlet Lothar Kimmeringer <news200709@kimmeringer.de> - 2012-12-30 14:47 +0100
    Re: POSTing to a servlet Arne Vajhøj <arne@vajhoej.dk> - 2012-12-30 15:37 -0500

csiph-web