Deploying and testing the opening page

To test it, you need to deploy it into the Container (Tomcat) directory structure, start Tomcat, and bring up the page in a browser.

  1. Create the HTML in your development environment Create this HTML file, call it form.html, and save it in your development environment under the /beerV1/web/ directory.

    image with no caption
  2. Copy the file into the deployment environment Place a copy of the form.html file into tomcat/webapps/Beer-v1/. (Remember, your tomcat home directory might have a different name).

  3. Create the DD in your development environment Create this XML document, name it web.xml, and save it in your development environment under the /beerV1/etc/ directory.

    image with no caption

The main job of this DD is to define the mapping between the logical name the client uses for the request (“SelectBeer.do”) and the actual servlet class file (com.example.web.BeerSelect).

  1. Copy the file into the deployment environment

    Place a copy of the web.xml file into tomcat/webapps/Beer-v1/WEB-INF/.

    You MUST place it there or the Container won’t find it and nothing will work, and you’ll become depressed.

    image with no caption
  2. Start Tomcat

    Throughout this book we’re using Tomcat as both the web Server and the web Container. In the real world, you probably use a more robust Web Server (like Apache) configured with a Web Container (like Tomcat). But Tomcat makes a perfectly decent Web Server for everything we need to do in this book.

    To start Tomcat, cd into the tomcat home directory and run bin/startup.sh.

    image with no caption
  3. Test the page

    Open the HTML page in your browser and type:

    http://localhost:8080/Beer-v1/form.html

    You should see something like the screen shot here.

    image with no caption
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset