Tirtha
Tirtha

Reputation: 351

How to Authenticate android app with tomcat sever?

I am working on an application where I want to send an HTTP post to my Tomcat sever. In this post,I want to send the user-id as well as password and after successful authentication from TomCat it will respose to my app, I I want next-page to display in my emulator? Any procedure or framework on this aspect ...that I have to use.

I am posting the code to post the request and get response.

public class Register extends Activity
{
public static final String PREFS_NAME = "LoginPrefs";
public static final String USER_NAME = "USER";

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register);
    TextView txt = (TextView) findViewById(R.id.textView1);
    txt.setText(getPage());
}


private String getPage() 
{
    String str = "***";

    try
    {
        HttpClient hc = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://www.yahoo.com");

        HttpResponse rp = hc.execute(post);

        if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
        {
            str = EntityUtils.toString(rp.getEntity());
        }
    }catch(IOException e){
        e.printStackTrace();
    }  

    return str;
}


}

Now u help me with how to send data with request and server will check the incoming data if data is present in database that will ensure that user is a valid user and send some response depending on that response i will navigate to next page. How will do this? Please help since i am new to java and android.

Upvotes: 0

Views: 451

Answers (1)

Anders Metnik
Anders Metnik

Reputation: 6237

take a look at this first response from a google search here

Upvotes: 1

Related Questions