CS/CIS 330 Spring 2004,
Homework 1a:
Tomcat Installation
This assignment is due on
2/9/2004 at 23:59pm via the course management system. You must
perform this assignment individually; groups are not permitted.
Project
Description
This
handout provides instructions for installing and configuring the Apache Tomcat
server program on your laptops. This
assignment teaches you how to setup the software. Please follow the following instruction to
install the newest
version of Tomcat 5. We will be
using Tomcat 5.0.18. To get the
installation file, please go to download à binary à find tomcat 5.xx... then save either the zip or
exe file.
Instructions
- General Tomcat
Installation Instructions Here
- Install the Java SDK (Software
Developer Kit) (http://java.sun.com/)
to C:\JDK
- Install the Apache Tomcat Web
Software (http://www.apache.org/)
- Configure Tomcat to use as the
ROOT directory C:\CS330
- Install the Microsoft
SQL JDBC drivers. Installation
simply requires you to place the Java classes in the appropriate
directories.
- Using your newly setup server,
write a JSP that prints out a table in HTML containing the factorials from 1 to 20, one on each row
of the table. The output should be
extremely simple but should be in the form of an HTML table and
also nicely formatted. By looking
at the table, we should know 10! = 3628800. In
addition, have it print out the URL string used to call the JSP in a line
after the table.
For the list, print the numbers using a valid
Java for loop. In this manner, the JSP code should be for
this part should really be 1-2 lines long, not 10 lines. Also, write the header/footer for the table
as well as the HTML tags (like <body>,<title>) in HTML, not JSP. As an
example, consider the following code where only the “Hello” statement is
written in JSP, the rest is just regular HTML:
<HTML>
<BODY>
<%
out.println("Hello"); %>
</BODY>
</HTML>
- Write a Servlet that
accomplishes the same task as your JSP called FactorialList.
Hints:
The
way you put java.exe and javac.exe into the path in WindowsXP is the following:
Control Panel à Systems à Advanced à Environment Variables à Under System Variables à path à Then, Add the correct
Java and javac path(ex: C:\j2sdk\j2sdk1.4.2\bin) into the path. You have to restart your computer before you
can execute javac in command line.
- You have to find and install
the Microsoft SQL JDBC
drivers. Although not used in this
assignment, they will be used later one a great deal. Installing them is just a matter of
placing three jar files in the right Tomcat directory. Hint: Place them in
TomcatInstallationDir\server\lib.
- Create a directory CS330 in C:\
as you will be working in this directory for future assignments.
- We recommend during the install
of the Java SDK to change the install path location to “C:\JDK” just to
make things easier on yourself in the future.
During Tomcat
Installation:
- HTTP/1.1 Connector Port changes
to 80 instead of 8080. Once changed,
you can just use the URL string http://localhost
to access your server once live. By
default, you must use http://localhost:8080
to access your server.
- Please set a password for admin
login
- Select the correct path for the
Java Virtual Machine (JVM) (Ex: C:\j2sdk\j2sdk1.4.2\ NO bin here).
Changing the Default
Server Path
After
you finishing testing the server, which is step 3. You can now change
application base to C:\CS330 in the following way:
- Shutdown tomcat if it is
running.
- Go to the apache tomcat
installation directory (ex: C:\Program Files\Apache Software
Foundation\Tomcat 5.0)
- Copy the whole webapp folder
and paste it to c:\CS330.
- Now, you have the same
structure as the default tomcat. Later on, you can just develop your code
or test your code under C:\CS330\webapps\ROOT\.
- Look for
<Context path=""
docBase="c:\CS330\webapps\ROOT" debug="0"/>
in Server.xml.
Notice the change I have made above(added C:\CS330\webapps\), please make that change in your server.xml file.
- Restart Tomcat
If you have trouble
installing Tomcat, please come to the office hours, we will be more than happy
to help you.
What to
Submit
In a zip file called A1a.zip submit:
- 1 JSP called list.jsp based on the instructions
above
- 1 Servlet called FactorialList.java based on the instructions above
- 2 Output files called output1.html and output2.html showing the results
of the JSP and Servlet on your server.