I am trying to access a servlet from my android application. my code looks like this
I am getting an error "connection refused"
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.
localhost/127.0.0.1:8080- Connection refused
with tomcat server OFF--> nothing happens
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?
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.
It will be very very helpful if you send me the code for both client and server.
Thanks in advance.