How to deploy a Servlet on TomCat?

I am new to tomcat web server.

I just wrote a helloworld  servlet and then wrote a .html document to embed the class file.
I dropped the .html file in the d:\tomcat 4.1\webapps\examples\servlets directory.

Then I dropped the class file in the d:\tomcat 4.1\webapps\examples\WEB-INF\classes directory

Then I opened a brower and typed

Ok the html script started. But the class file was not executed as I cannot see the result of that
coming out.

What did I do wrong?

PS. Web Server is running fine. I have a shell showing that.

Here is are my code....

<!-- MyHelloWorld.html -->
        Servlet HTTP GET Example
                 <P> Click the button to have the servlet send an HTML document</P>
                             <INPUT TYPE="submit" VALUE="Get HTML Document">

and the servlet class is....
      import javax.servlet.http.*;

      public class MyHelloWorld extends HttpServlet

          public void doGet(HttpServletRequest request,
                     HttpServletResponse response)
                                  throws IOException
          PrintWriter out = response.getWriter();
          out.println("<title>Hello World, I Just Started Servlets!</title>");
          out.println("<h1>Hello World,  I Just Started Servlets!</h1>");

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You'll have to edit the web.xml file in \examples\WEB_INF\ to add an entry for your servlet




also in your HTML change the form submitaction to


you dont actually need an html page to call the servlet youcan just put the url http://localhost:8080/webapps/examples/MyHelloWorld
in your browser

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.