Getting Hello World to show up on Tomcat
843842Nov 24 2008 — edited Nov 27 2008I am trying to get a HelloWorld program to run on Tomcat 4.1 on Unix, but when I visit the applet from my web browser, I get a 500 error. This is what I am doing...
I have added written HelloWorld.java like this:
class HelloWorld {
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
...and compiled it in the /examples/WEB-INF/classes directory. I run "java HelloWorld" at the command prompt and I get the output at the command line "Hello World!".
I have my /examples/WEB-INF/web.xml and added these lines:
<servlet>
<servlet-name>HelloWorld</servlet-name>
<display-name>HelloWorld</display-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
When I go to: domain:port/examples/servlet/HelloWorld, I get the 500 server error and this error description:
javax.servlet.ServletException: Error instantiating servlet class HelloWorld
When I change my <servlet-class> to HelloWorld.class I get the 500 error and this description:
javax.servlet.ServletException: Wrapper cannot find servlet class HelloWorld.class or a class it depends on
Does anyone have an idea whats going wrong? Why the 500 error? And why don't I see the most beautiful words of "Hello World!" on my browser? :-(