and Tomcat Installation
This handout assumes you have Eclipse J
2EE, and Tomcat 7.0 installed and have
completed the Handout Titled “Eclipse Setup for Developing Java Servlets”
Once you have downloaded Eclipse J2EE you should be able to create a
HelloWorld project and see it run in the console to verify your Java JDK/JRE
are installed correctly and Eclipse can see them.
Part 1 of this handout titled
“Eclipse Setup for Developing
Java Servlets” documents the procdure for
installing and testing the Eclipse Java EE install and test procedure to display
a HTML page.
Search for Tomcat 7.0 Download, move to where you keep user installed
programs, unarchive and test. Install instruction
Once you have downloaded Apache Tomcat 7.0 and installed it, you should
be able to start the server and see the default Apache Tomca
t page at
iguring Eclipse: add the Tomcat Server Runtime to Eclipse. Select
under Mac or
You should see a screen similar to the one below after you have selected a
Server Runtime. This tells Eclipse where the server is located so it can run
the server from inside Eclipse.
You should see 2 new entries, one in the Project E
xplorer with Servers and
one in the bottom pane window for Servers where your System.out.println
Console is when you run the HelloWorld Program to test the Java Console
e Eclipse J2EE Setup
for Servlet Development
test your Dynamic Web Project is functioning correctly, create a simple
Servlet to make sure Tomcat is installed correctly.
Create a project or use the Test project from the previous handout. Create a
new Servlet by right clicking on src>>New Servlet
Name the servlet FirstServlet
Click Finish and you should see:
If there are a bunch of red error marks it is because we haven’t included the
server runtime in the project yet.
Right click on the project Test, not the src folder. Select
onfigure Build Path
Click on the Libraries tab on the upper bar, it should be highlighted blue.
Click on Add Library:
Select Server Runtime;
Select Apache Tomcat v 7.0 and hit Next
Hit OK and you should see the red marks in the editor disappear:
Find the method doGet, and enter in the following code:
response.getWriter().write(“This is a test”);
Save the file using cntl
s or command
Right click on src>
>default package>>FirstServlet.java and select Run
This will take a couple seconds for the servlet to start, you will see red text
being displayed in the bottom part of the IDE as the server is being initialized
and the servlet code i
s being loaded into the Tomcat container. You should
see the same display as above.