944,021 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 2328
  • Java RSS
Mar 14th, 2007
0

Java ME App calling a servlet

Expand Post »
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:

Java Syntax (Toggle Plain Text)
  1. if (command == select && currentForm == login)
  2. {
  3. HttpConnection connection = null;
  4. InputStream inputstream = null;
  5.  
  6. try
  7. {
  8. int id = Integer.parseInt(loginTF[0].getString());
  9. }
  10. catch (NumberFormatException e)
  11. {
  12. System.out.println("Invalid number type" + e);
  13. }
  14. String pword = loginTF[1].getString();
  15.  
  16. try
  17. {
  18. connection = (HttpConnection) Connector.open("http://localhost:8080/nurse/NurseServer.doPost?method=login&userID="+id+"&password="+pword);
  19. connection.setRequestMethod(HttpConnection.GET);
  20. connection.setRequestProperty("Content-Type", "//textplain");
  21. connection.setRequestProperty("Connection", "close");
  22. }
  23. catch (IOException e)
  24. {
  25. System.out.println("Error at client login: " + e.toString());
  26. }
  27. }

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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
mr.sweetchuck is offline Offline
27 posts
since Feb 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Asterisks Pattern Help!
Next Thread in Java Forum Timeline: JRE1.4.2_13 Proxy Configuration:No proxy





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC