Hi guys!
I'm making an app that must login on the server to run...
Here's the app code:
Code:
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.103:8080/Teste");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(2);
postParameters.add(new BasicNameValuePair("login", "daniel"));
postParameters.add(new BasicNameValuePair("senha", "1234"));
httppost.setEntity(new UrlEncodedFormEntity(postParameters));
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
Log.d("DEBUG", response.getStatusLine().getStatusCode()+"");
With this, my app can connect to the server. See the code on server:
Code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
//Pega os parâmetros da página
String login, senha;
login = request.getParameter("login");
senha = request.getParameter("senha");
System.out.println(login);
System.out.println(senha);
if(login!=null && !"".equals(login) && senha!= null && !"".equals(senha))
{
response.sendRedirect("login.jsp");
}
else
response.sendError(response.SC_BAD_REQUEST);
%>
Here's the problem.... the paremeters are always "null". Why? What I'm doing wrong?
Any help will be great!
Thank you all!