Java ME App calling a servlet

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2007
Posts: 27
Reputation: mr.sweetchuck is an unknown quantity at this point 
Solved Threads: 1
mr.sweetchuck mr.sweetchuck is offline Offline
Light Poster

Java ME App calling a servlet

 
0
  #1
Mar 14th, 2007
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:

  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.
Nel sogni, come in amore, non ci sono cose impossible
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1733 | Replies: 0
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC