clave app android,java - Simple http post call not working with android app - Stack Overflow

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?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值