File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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

Connect Wireless Toolkit with Apache Tomcat in localhost

George Kalfas

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 : (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 "" or with any other URL on the web (ie. 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: 16020

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

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

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

Apparently in my windows machine localhost does not translate to 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 is locahost...
Joao Eduardo Galli

Joined: May 02, 2007
Posts: 6

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

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
I agree. Here's the link:
subject: Connect Wireless Toolkit with Apache Tomcat in localhost