Note that you will not be able to do any of the exercises listed below until you have
set up the Java servlet API, as described in Sect. 8.2 .
8.1 (i) Following the procedure outlined in Sect. 8.3 , set up the folder structure
for a Web application with a name of your own choosing.
(iv) Create a deployment descriptor (fi le web.xml) within your WEB-INF
folder and enter <servlet> and <servlet-mapping> tags for servlet
(iii) Copy PersonalServlet.java from Sect. 8.7 into the classes folder of your
Web application and copy PersonalServlet.html from the same section
into your Web application's root folder (the one just below webapps in the
Tomcat hierarchy). Compile PersonalServlet.java .
(iv) Open a command window and start Tomcat running with the startup
command (or double-click on fi le startup.bat in ÇATALINA_HOME\bin ).
Start up a Web browser and enter the following address:
Enter your name and click on 'Submit'.
Modify the above Web page and servlet so that the POST method is used to
send both the user's name and his/her email address. The Web page returned
should display the user's email address below the original message.
(ii) Once the servlet has been compiled without error, execute the command
shutdown in the initial command window and then re-start the server.
Use your browser to test your new servlet.
8.3 (i) Copy AdderServlet.java from Sect. 8.7 into your classes folder and
SimpleAdder.html from the same section into your Web app's root folder.
Then compile the Java servlet.
(ii) Add the appropriate <servlet> and <servlet-mapping> tags for the above
servlet to your deployment descriptor.
(iii) Start up Tomcat (stopping it fi rst, if it is already running) and access the
above Web page via any browser (as for the preceding programs).
(iv) Enter integers into the two text boxes, as prompted, and click on 'Submit'.
8.4 (i) Copy ShoppingCart.html from Sect. 8.8 into your Web app's root folder.
(ii) Create your own Selection servlet, placing it in the classes folder. This
servlet should generate a Web page that simply displays the name of the
product selected by the user.
(iii) Add the appropriate tags to your deployment descriptor and compile the
Start up Tomcat (stopping it fi rst, if it is already running) and then test the
servlet by accessing ShoppingCart.html in your browser window.