954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java ME App calling a servlet

I'm writing a Java ME app that will access servlets on a tomcat server, (version 5.5) and I'm having a problem. In my client I'm trying to use a HTTP connection to the servlet, like so:

if (command == select && currentForm == login)
{
    HttpConnection connection = null;
    InputStream inputstream = null;
                
    try
    {
           int id = Integer.parseInt(loginTF[0].getString());
    }
    catch (NumberFormatException e)
    {
           System.out.println("Invalid number type" + e);
    }
    String pword = loginTF[1].getString();

    try
    {
          connection = (HttpConnection) Connector.open("http://localhost:8080/nurse/NurseServer.doPost?method=login&userID="+id+"&password="+pword);
          connection.setRequestMethod(HttpConnection.GET);
          connection.setRequestProperty("Content-Type", "//textplain");
          connection.setRequestProperty("Connection", "close");
    }
    catch (IOException e)
    {
          System.out.println("Error at client login: " + e.toString());
    }
}


I'm running it on an emulator on the machine, which is compiling the code. However it is giving me an cannot find symbol error and pointing to the URL.

Additional info:

localhost:8080/nurse is a webservice that I've deployed.
I've tried using the ip address of the machine instead, but I'm getting the same error again.
Tomcat is running.
NurseServer is the class that I want to call, (which is compiled propperly).
doPost is the method that, from what I'm understand, you have to call from the client.

Any suggestions as to what is the problem? Any addition info need, just ask.

mr.sweetchuck
Light Poster
27 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You