Install the Java Runtime Environment and Tomcat 5.0.5
The first thing you need to do is download the Java 2 SDK
and install it. As I write this the latest version is 1.4.2. Download the Windows installation from the SDK column under "Download J2SE 1.4.2." Run the installer with all the defaults.
You'll also need a JSP 2.0 compliant application server. Download Tomcat 5.0.5
and install the directory at the root of your drive. Call it C:\Tomcat 5.0\.
Start the server (Start -> All Programs -> Apache Tomcat 5 -> Start Tomcat
). Then open a Web browser and browse to http://localhost:8080
. You should see there, displayed in all its glory, the Tomcat 5.0 welcome page. If you want, you can take a few minutes to check out the example pages http://localhost:8080/jsp-examples/
There are many folders under the C:\Tomcat 5.0\
directory, but right now we are only interested in the C:\Tomcat 5.0\webapps\ROOT
folder. This will be our playground for the rest of this article.
Configure and Install Needed Libraries
Under the ROOT folder there are a few files and a folder called WEB-INF
is a part of all Java 2 Web applications and is not exposed to the Web user through a URL such as //localhost/:8080/WEB-INF
. The WEB-INF folder holds the application configuration, the Java libraries required for your application, and any Java classes that you create.
Create a directory named lib
in your WEB-INF folder (i.e. C:\Tomcat 5.0\webapps\ROOT\WEB-INF\lib
). Copy the files standard.jar
from C:\Tomcat 5.0\webapps\jsp-examples\WEB-INF\lib
and put them into your new lib
directory. These are library components (.jar
files) that will have to be available to your application to complete this tutorial.
Download the appropriate Java database drivers (also .jar
files) and place them into the lib
directory you just created. The example code uses a SQL Server database, so you will need the database drivers (.jar files) provided by Microsoft
(click on "SQL Server 2000 Driver for JDBC"Read our review
of the driver). The executable for the SQL Server 200 Driver for JDBC installs .jar
files and Help documentation onto your computer. You will need to copy the three .jar
files from its install directory into your WEB-INF/lib
Now you need to modify the application's configuration file, named web.xml
. Open the web.xml
file (C:\Tomcat 5.0\webapps\ROOT\WEB-INF\web.xml
) and locate, toward the top, the opening XML tag <web-app>
. Replace this opening tag with:
Save and close the web.xml
file, right click the Tomcat icon in the system tray, and select Shutdown. Then restart it again from your Start menu. You can make some changes without restarting, but restarting is generally a good way to confirm that your changes are loaded and in effect.
Now you have a platform onto which you can unleash your brilliant Java Powered mind!