//open stream on URL
InputStream inputStream = null;
try {
            URLConnection urlConnection = url.openConnection();
            urlConnection.setConnectTimeout(value); // here value is an int.
value
            urlConnection.setReadTimeout(value1);  // here value1 is an int.
value
            inputStream = urlConnection.getInputStream();
        }
        catch (SocketTimeoutException e){
            Log.v("httpRequest", e.getMessage());
       } catch (IOException e) {
            Log.v("httpRequest", e.getMessage());
      }

        //Read the stream , create stream reader
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);

//create buffered reader
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

        //read line by line from buffered reader.
String line = null;
String data = "";
try {
            while((line = bufferedReader.readLine()) != null){
data = data.concat(line.toString());
            }
} catch (IOException e) {
    Log.v("httpRequest", "Buffer reading issue");
}

try {
            bufferedReader.close();
} catch (IOException e) {
            Log.v(":httpRequest", e.getMessage());
        }

NOTE : Remember to do this task in separate thread or use AsyncTask class of
Android...

Cheers
Dalvin

On Sat, Mar 19, 2011 at 11:51 PM, kajal patil <[email protected]>wrote:

> Hi All,
>   I developed an android application.I want to send http request from my
> android application on button click to servlet in eclipse.But I am not able
> to send http request to my servlet from my android application.I have
> searched a lot but i didn't get any correct code.Can u please give me some
> solution to perform this operation?
> Thank you.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to