Developing a simple Java web application using Eclipse and Apache Tomcat - Part 2

by Steve Ochani http://www.steveo.us

v 1.0 April 26th, 2010.

Purpose: To show how to make a web application in Java using Eclipse and the Apache Tomcat java servlet container/application server.

Intended audience: This tutorial is mainly intended for students taking ITE 204 (Java Programming) course at SUNY Nassau Community College but is still relevant to anyone wishing to develop a J2EE web application in Java. You should have at least basic knowledge and understanding of object oriented programming concepts in Java and know how to use Eclipse.

Structure of this document: This tutorial is split up into easy steps each containing text and thumbnails of screenshots. You can click on the thumbnail to see the full size screenshot (except the very first one).

Pre-requisite: Read Part 1 of this tutorial -

Download and unzip Apache Tomcat 6 from either from Apache Tomcat's website (get the zipped version) or http://stargate.ncc.edu/tomcat/. I then recommend you unzip Tomcat into the same drive where you put your Eclipse workspace, for example J:\ (for people working on the college network)

 

This tutorial will build upon the application created in Part 1. It will show how to read input from radio buttons, checkboxes and drop down lists.

 

1. Open up the project from Part 1 and modify the index.html to the following to add more form components.

 

2. Now modify the doPost method in the servlet to the following:

 

3. Now select the index.html and run the application. Your application should launch in a browser, fill out the form and click the button "Click here"

 

and you will receive the output from the servlet such as the following.