Problem in Http Get Method..pls tell me..

by ragavendran s » Wed, 02 Sep 2009 22:12:17 GMT


Sponsored Links
 can u tell me how to send the Url to the server using Http Get method...

Here i m trying to insert a name into the databse .If i execute the below

showing code  there it tells "Connection to  http:localhost refused "

 i think the error is is in the Http method ..Would u tel me pls how to
Correct
it....


With ragards,

Raghav.S



My Code:


package simpl.http1;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class simplhttp1 extends Activity {
    /** Called when the activity is first created. */


    Button enter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        enter=(Button)findViewById(R.id.enter1);


        enter.setOnClickListener(new OnClickListener(){

            public void onClick(View v)
            {

                openconn();


            }
        });



    }

   public void openconn()

   {

                 String str11="murugan";
               String feed_url="
http://localhost:8080/Serv1/servlet/Servlet1?st1="+str11;
              HttpClient client=new DefaultHttpClient();
              HttpGet siteRequest = new HttpGet(feed_url);
              try {
                HttpResponse httpResponse = client.execute(siteRequest);
                TextView t = (TextView) findViewById(R.id.myTextView);

                 t.setText("Ok");
            } catch (ClientProtocolException e) {

                TextView t = (TextView) findViewById(R.id.myTextView);
                t.setText(e.getMessage());
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                TextView t = (TextView) findViewById(R.id.myTextView);
                t.setText(e.getMessage());
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

   }



}

--~--~---------~--~----~------------~-------~--~----~



Problem in Http Get Method..pls tell me..

by Urs Grob » Wed, 02 Sep 2009 23:44:28 GMT


 localhost is the device itself, not your host where the emulator is running
on. If I remember correctly you would have to use 10.0.2.2 instead of
localhost.

-- Urs





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Is there a visual guide to Android components?

Hello

As someone who is fairly new to Java I use online documentation and
other resources very often to either to jog my memory or to learn
something new. As a visual learner and frequent user of Sun's Java
tutorials I find a lot of comfort in images and diagrams.

Sun has a great section titled "A Visual Guide to Swing Components
(Java Look and Feel)" which can be found here:
http://java.sun.com/docs/books/tutorial/ui/features/components.html
which names each Swing component and then has an example image of them
in action. I found a section similar to this for the Android
components in the Dev Guide but I can't seem to find it again. Does
anyone know where this is or another resource which provides something
similar?

--~--~---------~--~----~------------~-------~--~----~

2. Error Message

Hi,

I am trying to render an OpenGL model and my Activity dies. I think it  
might be running out of memory or something.

Can anyone help me understand the following error message?

Thanks for any help.

05-17 10:23:58.436: INFO/DEBUG(539): *** *** *** *** *** *** *** ***  
*** *** *** *** *** *** *** ***
05-17 10:23:58.442: INFO/DEBUG(539): Build fingerprint: 'generic/sdk/ 
generic/:1.5/CUPCAKE/147336:eng/test-keys'
05-17 10:23:58.442: INFO/DEBUG(539): pid: 4686, tid: 4843  >>>  
edu.union <<<
05-17 10:23:58.452: INFO/DEBUG(539): signal 11 (SIGSEGV), fault addr  
001cc000
05-17 10:23:58.452: INFO/DEBUG(539):  r0 00000000  r1 0000008e  r2  
80000000  r3 00000000
05-17 10:23:58.452: INFO/DEBUG(539):  r4 001cbff8  r5 456a1ce0  r6  
001ca620  r7 001c4d50
05-17 10:23:58.462: INFO/DEBUG(539):  r8 0000098e  r9 0000000c  10  
00000000  fp 001c7240
05-17 10:23:58.462: INFO/DEBUG(539):  ip 456a1cf0  sp 456a1c60  lr  
acc081a0  pc acc081a4  cpsr 40000010
05-17 10:23:58.562: INFO/DEBUG(539):          #00  pc 000081a4  / 
system/lib/libagl.so
05-17 10:23:58.562: INFO/DEBUG(539):          #01  pc 0000b420  / 
system/lib/libagl.so
05-17 10:23:58.572: INFO/DEBUG(539):          #02  pc 0000fa9c  / 
system/lib/libagl.so
05-17 10:23:58.582: INFO/DEBUG(539):          #03  pc 000118e0  / 
system/lib/libagl.so
05-17 10:23:58.582: INFO/DEBUG(539):          #04  pc 000078cc  / 
system/lib/libagl.so
05-17 10:23:58.592: INFO/DEBUG(539):          #05  pc 00009068  / 
system/lib/libagl.so
05-17 10:23:58.602: INFO/DEBUG(539):          #06  pc 0000e3b4  / 
system/lib/libdvm.so
05-17 10:23:58.612: INFO/DEBUG(539): stack:
05-17 10:23:58.622: INFO/DEBUG(539):     456a1c20  456a1d00
05-17 10:23:58.622: INFO/DEBUG(539):     456a1c24  00000000
05-17 10:23:58.622: INFO/DEBUG(539):     456a1c28  001ca4b0  [heap]
05-17 10:23:58.632: INFO/DEBUG(539):     456a1c2c  0000000c
05-17 10:23:58.632: INFO/DEBUG(539):     456a1c30  001c8344  [heap]
05-17 10:23:58.642: INFO/DEBUG(539):     456a1c34  acc10c70  /system/ 
lib/libagl.so
05-17 10:23:58.642: INFO/DEBUG(539):     456a1c38  0000d7c4  [heap]
05-17 10:23:58.642: INFO/DEBUG(539):     456a1c3c  00000000
05-17 10:23:58.642: INFO/DEBUG(539):     456a1c40  00000001
05-17 10:23:58.642: INFO/DEBUG(539):     456a1c44  00000203
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c48  00001120
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c4c  001ca520  [heap]
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c50  001ca420  [heap]
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c54  001ca4a0  [heap]
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c58  df002777
05-17 10:23:58.652: INFO/DEBUG(539):     456a1c5c  e3a070ad
05-17 10:23:58.663: INFO/DEBUG(539): #00 456a1c60  fffffef7
05-17 10:23:58.672: INFO/DEBUG(539):     456a1c64  456a1ce0
05-17 10:23:58.672: INFO/DEBUG(539):     456a1c68  001ca520  [heap]
05-17 10:23:58.682: INFO/DEBUG(539):     456a1c6c  acc0b424  /system/ 
lib/libagl.so
05-17 10:23:58.682: INFO/DEBUG(539): #01 456a1c70  0000999a
05-17 10:23:58.682: INFO/DEBUG(539):     456a1c74  00004ccd
05-17 10:23:58.682: INFO/DEBUG(539):     456a1c78  00000000
05-17 10:23:58.692: INFO/DEBUG(539):     456a1c7c  00000978
05-17 10:23:58.692: INFO/DEBUG(539):     456a1c80  acf19ec4
05-17 10:23:58.692: INFO/DEBUG(539):     456a1c84  000000e6
05-17 10:23:58.702: INFO/DEBUG(539):     456a1c88  00000002
05-17 10:23:58.712: INFO/DEBUG(539):     456a1c8c  00000000
05-17 10:23:58.712: INFO/DEBUG(539):     456a1c90  001ca5a0  [heap]
05-17 10:23:58.722: INFO/DEBUG(539):     456a1c94  00000e68
05-17 10:23:58.733: INFO/DEBUG(539):     456a1c98  00000001
05-17 10:23:58.733: INFO/DEBUG(539):     456a1c9c  ffffffff
05-17 10:23:58.733: INFO/DEBUG(539):     456a1ca0  00de1401
05-17 10:23:58.742: INFO/DEBUG(539):     456a1ca4  0043b400
05-17 10:23:58.742: INFO/DEBUG(539):     456a1ca8  00000140
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cac  ffff7334
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cb0  00000000
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cb4  acf0a97c  /system/ 
lib/libpixelflinger.so
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cb8  00000008
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cbc  00001ad8
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cc0  00003333
05-17 10:23:58.752: INFO/DEBUG(539):     456a1cc4  00000e68
05-17 10:23:58.762: INFO/DEBUG(539):     456a1cc8  456a1cec
05-17 10:23:58.772: INFO/DEBUG(539):     456a1ccc  456a1cdc
05-17 10:23:58.772: INFO/DEBUG(539):     456a1cd0  00000e68
05-17 10:23:58.772: INFO/DEBUG(539):     456a1cd4  456a1cfc
05-17 10:23:58.772: INFO/DEBUG(539):     456a1cd8  0000f8ab  [heap]
05-17 10:23:58.772: INFO/DEBUG(539):     456a1cdc  00de1401
05-17 10:23:58.782: INFO/DEBUG(539):     456a1ce0  00000000
05-17 10:23:58.782: INFO/DEBUG(539):     456a1ce4  00000000
05-17 10:23:58.782: INFO/DEBUG(539):     456a1ce8  00000e68
05-17 10:23:58.782: INFO/DEBUG(539):     456a1cec  00010000  [heap]
05-17 10:23:58.792: INFO/DEBUG(539):     456a1cf0  00003333
05-17 10:23:58.802: INFO/DEBUG(539):     456a1cf4  00003333
05-17 10:23:58.802: INFO/DEBUG(539):     456a1cf8  00003333
05-17 10:23:58.802: INFO/DEBUG(539):     456a1cfc  00010000  [heap]
05-17 10:23:58.802: INFO/DEBUG(539):     456a1d00  d762a9d6
05-17 10:23:58.802: INFO/DEBUG(539):     456a1d04  001c7240  [heap]
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d08  001ca520  [heap]
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d0c  001ca620  [heap]
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d10  001ca620  [heap]
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d14  00000000
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d18  00000994
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d1c  00000000
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d20  00000001
05-17 10:23:58.812: INFO/DEBUG(539):     456a1d24  acc0faa0  /system/ 
lib/libagl.so

--~--~---------~--~----~------------~-------~--~----~

3. - Play video in Android Media Player from given UR

4. Slow time zone name loading

5. How to import an existing project into Eclipse?

6. How to donwload a free app from android market?

7. How to donwload a free app from android market?