This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hello Guys, I've been following the discussions about the HelloWorld servlet not working in Tomcat v4.1.27. Since I suffer from the same problem I tried a few of the suggested solutions last night but to no avail. I am running Redhat 9, Java SDK 1.4, J2EE1.2 & Tomcat 4.1.27 LE. There were two main solutions to this problem: 1. Uncomment the following line in the web.xml file ( in conf dir ). <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*<url-pattern> <servlet-mapping> Stop / Start Tomcat. This should have allowed me to view the URL http://localhost8080/myApp/HelloWorld However I still got the 404 page not found error. 2. Next I looked at the examples which come with Tomcat & work. They have the <servlet-mapping> & <url-pattern> tags in the applications web.xml file. So I edited my HelloWorld's web.xml & inserted these lines. Stopped/started Tomcat but it still didn't work. The only othre difference between the examples web.xml & my is a load of stuff about filters? Can anybody help as I'm beginning to feel a lot of resentment towards Tomcat!!! Cheers - Michael.
The next thing to check is - do you have everything set so Tomcat will consider /myApp/ to be a web application with HelloWorld as a servlet? Where is the myApp directory? Where is your HelloWorld class file? Bill
Following along the lines of Bill Questions. What package is HelloWorld in? If it's not in a package, maybe that's the cause. Give it a package say hello, rebuild it and put the class under WEB-INF/classes/hello Now your URL should be http://localhost:8080/myApp/servlet/hello.HelloWorld
Hello Guys, Sorry for not getting back to you earlier! In answer to Bills Question: the directory path is /webapps/myApp/WEB-INF/classes The web.xml file is in the WEB-INF directory. The java files are in the classes directory. In Answer to Karls question: My Helloworld class is not a member of any package? Why does it need to be? I'll have to check the examples directory in Tomcat but I don't believe they are a part of any package. However I will try your suggestion. I just can't see why the examples work, but my code doesn't?? Thanks - Michael