Note that 10.0.2.2 is the "magic" IP address you'd use if running the app in the emulator. If you run it on the actual device (maybe over a WLAN) then you need to use the IP address assigned by the router to the desktop machine, which is propably something like 10.0.1.2.
Bilal A.Siddiqui wrote:I am running this app in an emulator. my application is just sending "get" request to a servlet which is mapped in web.xml
but i am getting connection refused.
And you will, until the message stops returning the localhost IP address 127.0.0.1. Something's still wrong with your URL.
Customer surveys are for companies who didn't pay proper attention to begin with.
Bilal A.Siddiqui
Ranch Hand
Joined: Feb 22, 2010
Posts: 31
posted
0
i have a doubt now whether this android activity knows about my servlet or not. I mean does it know to lookup for that in web.xml. i just felt so because whether tomcat server is ON or OFF the error is same.
I understand, you tried http://10.0.2.2:8080/getAndroid on the emulator with Tomcat Running and it did not work, correct? Have you tried what Ulf suggested? [Try IP address of your desktop machine]
Bilal A.Siddiqui
Ranch Hand
Joined: Feb 22, 2010
Posts: 31
posted
0
hi monu
i tried with my system ip also but the result was same. now i am confused because whether my tomcat server is running or not its giving same error. am i making any mistake in project structure??
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
i just felt so because whether tomcat server is ON or OFF the error is same.
Can you make ANY network connections, for example using the browser? Does the machine have a firewall that's blocking incoming connections?
depending on what is the default Time Out interval set for HttpClient, your code may either block indefinitely or will get an TimeOutException.
with tomcat server running--> i get 404 status
This is classic Resource not found; are you sure your service is deployed on the server? Can you try it out from your browser?
Additionally:
1. Check if you can access other sites from your emulator.
2. Change the URL in your code to some thing more common like http://www.google.com and see if you get a valid response code.
---
If you are interested you can read up on Android Emulators Network Address Space mapping here.
Just to clarify on Monu: a 404 error comes from Tomcat. So you're definitely talking to the server now. However you haven't deployed the server application in a way that maps to your URL.
Bilal A.Siddiqui
Ranch Hand
Joined: Feb 22, 2010
Posts: 31
posted
0
i have done it !!! wow
i called get method of my servlet from my android app, its runninh well.
thanks to all
Durga Sanju
Greenhorn
Joined: Jun 03, 2010
Posts: 10
posted
0
Please send the code for connecting android with servlet. Yours is the first and foremost that you have successfully connected, because i have googled almost all the sites but nothing worked.
It will be very very helpful if you send me the code for both client and server.