Chapter 3 Servlet Basics
Contents A.Installing Eclipse WTP and configuring Tomcat B.Prime Number Problem C.Multiplication Table Problem
A. Installing Eclipse WTP and configuring Tomcat 1.Installing Eclipse WTP 2.Configuring Tomcat
1. Installing Eclipse WTP Download Eclipse IDE for Java EE aDevelopers at Extract the file eclipse-jee-europa-winter- win32.zip Run eclipse.exe file to start Eclipse
2. Configuring Tomcat Click Windows > Preferences… Preferences Server > Installed Runtimes Click Add…
Preferences (cont.) New Server Runtime Select the version of Tomcat you have installed Click Next
Tomcat Server Click Browse to specify the Tomcat home directory Click Finish
B. Prime Number Problem Write a program that shows all prime numbers from 1 to 1000 as below:
Solution 1. Creating New Dynamic Web Project 2. Developing the Servlet 3. Running the Project
1. Creating New Dynamic Web Project Click File > New > Project… New Project Dynamic Web Project > Next
New Dynamic Web Project Project name: PrimeNumbers Click Finish
2. Developing the Servlet 2.1. Creating Servlet Template 2.2. Developing doGet() 2.3. Developing the Model
2.1. Creating Servlet Template Click File > New > Other > Servlet
2.2. Developing doGet()
2.3 Developing the Model
2.4. Running the Project Right click to the Sevrlet -> Run As -> Run on Server
C. Multiplication Number Problem Write a program that shows the multiplication table as bellow:
Solution Project name: MultiplicationTable
References 1.Core Servlets And Java Server Pages, Volume 1, 2 nd Edition, Chapter 3