• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connect Wireless Toolkit with Apache Tomcat in localhost

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
George Kalfas
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic