Wrox Programmer Forums
|
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2011, 05:05 PM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default android and internet

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cryptography and Android jhwong56 BOOK: Beginning Cryptography with Java 2 April 12th, 2011 09:10 PM
Android SDK/Android.bat does not find SWT.jar file chaoticandroid BOOK: Professional Android 2 Application Development 1 March 23rd, 2011 06:39 PM
Upgrade to Android 2.3 MellowFellow BOOK: Professional Android 2 Application Development 0 January 19th, 2011 02:19 PM
i am new to android janardhan BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 July 29th, 2010 03:37 PM
Internet Explorer cannot open the internet site cathiec ASP.NET 2.0 Basics 1 October 22nd, 2005 01:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.