0

I am trying to develop an Android application which typically allows users to login (authentication has to be done in the web application. I already have a Servlet which takes username and password and returns success or failure as result in XML format) with their credentials and do some operations (like view, update delete) on the data specific to that user.

I found that we have to use REST way of doing this. I am not sure if I understood it correctly. Can someone direct me the way I should proceed to develop this kind of Android application?

Thanks, Prasanth

Prasanth
  • 53
  • 3

1 Answers1

0

The easiest way I did this was using GET. Just load the credentials to your URL and load that url

username = et1.getText().toString(); password = et2.getText().toString();

String url = "http://www.abc.com?action=ru?loginid="+username+"paswd="+password; wv.loadUrl(url);

If you just do the above, you can see "successful" on your screen. If you want to catch this and put a validation, do the following:

                            InputStream isText = text.openStream();

                        byte[] bytes=new byte[isText.available()];
                        isText.read(bytes);
                        String s = new String(bytes);
                        System.out.println(s);

                        if(s.equals("unavailable"))

                        {

                        String s1="OK";
                    AlertDialog.Builder ad=new AlertDialog.Builder(Registration.this);

                           ad.setMessage("username already exists");
                           ad.setPositiveButton(s1, new DialogInterface.OnClickListener()
                           {
                                public void onClick(DialogInterface dialog, int which) 
                            {

                            }

                           });
                                   ad.show();

                        return;

                    }
Rashmi.B
  • 1,787
  • 2
  • 18
  • 34
  • Please note, the reply from the server maybe different. I have not used GET keyword. By default,I am fetching response from the server by loading the credentials...hope this helps – Rashmi.B Sep 29 '11 at 11:14
  • What security precautions should be considered when sending data (particularly the username/password combo) via `GET` this method? – ServAce85 May 29 '12 at 20:19
  • Normally people say using GET is not wise, where as POST is secure as it contains a key value pair, for encryption. Unless your server is not highly authenticated, it is fine to use GET. But if you feel, there is important data that needs to be shared only within yourself, then POSt approach is fine. – Rashmi.B May 30 '12 at 11:03
  • you can look for more info here [this link](http://stackoverflow.com/questions/198462/is-either-get-or-post-more-secure-than-the-other) – Rashmi.B May 30 '12 at 11:03