1. Create a web application structure as follows.(To know more about structure of web application )
  2. WebApp

  3. Create static.html as follows
  4. <html>
    <head>
     <title>Servlets</title>
    </head>
    <body>
     <h1>Welcome to Servlets</h1>
    </body>
    </html>
    
  5. Copy static.html page into WebApp(WEB-ROOT) directory.
  6. staticpage

  7. Final WebApp structure
  8. FinalStructure

  9. Create a war(web archive) using the jar command.
  10. CreateWarCommand

  11. In order to run a web application, the web application must be deployed in the container.
    We must copy the war file in webapps directory of tomcat.
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps
  12. Accessing web application static resource.Open the browser and type the following URL in the address bar
  13. http://localhost:9091/WebApp/static.html

    Ouput

Note:Instead of copying the war file to webapps we can copy the exploded directory structure of the web applications in webapps directory.

Download project:WebApp project
Download war file:WebApp.war