views:

67

answers:

2

Hi, I am absolutely new to android development and I need help in know how can I invoke a remote servlet which is gonna send me data from a database in the form of xml. I am a beginner and I don't understand jargon. If possible provide me with a link/tutorial for the same.

Any help is greatly appreciated, Thanks!

A: 

Hi

you need to do this while making a get request.

public boolean funtionAtSite(String sentUrl) {
        String url = sentUrl;
        HttpGet getMethod = new HttpGet(url);
        DefaultHttpClient client = new DefaultHttpClient();
        try {
            ResponseHandler<String> reponseHandler = new BasicResponseHandler();
            String responseBody = client.execute(getMethod, reponseHandler);
            /******** now do what you want to do with response **********/
            if (responseBody.equalsIgnoreCase("1")) {
                Log.v(TAG, responseBody);
                return true;
            }
                return false;
        } catch (Throwable t) {
            return false;
        }
    }
success_anil
I want to invoke a servlet and use its response object back in my application, your code didnt solve my problem, please check again.
andsri
Ok Friend what are you getting in response object from servlet
success_anil
Illegal State exception. It has nothing, it is going directly to other catch block.
andsri
Have you added Internet access permission in AndroidManifest.xml. This could shud work I 'm using it.
success_anil
A: 

No. The exception is still incact. I also added the permission.

andsripa
Hi Could you post your code snippet.
success_anil