Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting Hello World to show up on Tomcat

843842Nov 24 2008 — edited Nov 27 2008
I 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? :-(

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2008
Added on Nov 24 2008
6 comments
579 views