aspose file tools*
The moose likes Java Micro Edition and the fly likes Connect Wireless Toolkit with Apache Tomcat in localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Connect Wireless Toolkit with Apache Tomcat in localhost " Watch "Connect Wireless Toolkit with Apache Tomcat in localhost " New topic
Author

Connect Wireless Toolkit with Apache Tomcat in localhost

George Kalfas
Greenhorn

Joined: Aug 05, 2004
Posts: 22
Greetings everyone!

I've recently began programming Midlets, and I'm trying to write my first Midlet that uses http connection, but I have stumbled upon something.
First of all I used the code given in this article : http://developers.sun.com/mobility/midp/articles/permissions/ (under the section "Making an HTTP Connection". It is a very simple Midlet. The main code is this :



When I use the wireless toolkit to test it with the url "http://wireless.java.sun.com/" or with any other URL on the web (ie. www.google.com) I get good results.
In addition I have installed apache tomcat localy on my computer. When I give my browser a localhost address everything works fine. I have put a very simple html page for example that says Hello and when I give my browser the address "http://localhost/Hello.html" it displays it correctly.
But when I give the same address to my Midlet, it just says "Error ...".
What is wrong here?
After adding this line to the Midlet the wireless toolkit prints "404". How come the page displays correctly through Firefox, but the Tomcat returns a 404 to the Midlet?
Is my Midlet wrong somehow, or is my wireless toolkit configuration or tomcat not correct?

Thank you very much and in advance for your reply!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Are you sure it's Tomcat returning the 404? 404 is the HTTP standard status code for Page Not Found. You can get it any time an http request cannot be satisfied due to inability to resolve the URL. It includes situations where you're contacting a proxy web server that doesn't know how to pass the request along and if memory serves me correctly, you can also get 404's when DNS isn't working properly or when you haven't got a functional gateway (for example, when you're using WiFi to handle your web requests and the device hasn't connected to a gateway device such as a wireless router).


Customer surveys are for companies who didn't pay proper attention to begin with.
George Kalfas
Greenhorn

Joined: Aug 05, 2004
Posts: 22
Dear Tim,

Thanks a lot for your reply! Your answer made me think that I should try http://127.0.0.1/Hello.html instead of http://localhost/Hello.html and it worked!!!

Apparently in my windows machine localhost does not translate to 127.0.0.1 for some reason. I thought it would but it does not apparently. Does someone maybe know why?
The hosts file under C:\WINDOWS\system32\drivers\etc directory mentions that 127.0.0.1 is locahost...
Joao Eduardo Galli
Greenhorn

Joined: May 02, 2007
Posts: 6
George,

I think that when you use localhost you need to insert the port, in my case I use : "http://localhost:8080/app", and works fine.
George Kalfas
Greenhorn

Joined: Aug 05, 2004
Posts: 22
Dear Joao,

thanks for your reply!
The problem was not at appending the port number at the URL, since I configured Tomcat to use port 80 instead of 8080 cause I don't have another web server installed on my machine.
The problem is that the DNS that wtk uses does not translate localhost to 127.0.0.1.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connect Wireless Toolkit with Apache Tomcat in localhost