I've the following code in an android app:
DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost("http://127.0.0.1:8888/unidad6_eje1_conectarbd/ejecutaPOST");
List nameValuePairs = new ArrayList();
nameValuePairs.add(new BasicNameValuePair("value1", "Value my user entered"));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response=hc.execute(postMethod,res);
But it fails on its last line:
http://127.0.0 1: 8888/unidad6_eje1_conectarbd/ejecutaPOST
is likely to be configured properly to receive POST requests as if I put that URL in a web browser it gives the error: Error 405 HTTP method GET is not supported by this URL.
The code for the servlet is the following:
public class LoginImpl extends HttpServlet {
public static String nombre="";
String clave="";
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String value1 = request.getParameter("value1");
System.out.println(value1);
}
}
That I don't think should be an issue.
Can anyone give me any idea of what might be happening?