DOC PREVIEW
CMU ISM 95733 - Lab 1

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lab 1 Due Wednesday, January 30, 2002Tomcat Installation, WAR Files and Servlets95-733 Internet Technologies Carnegie Mellon University Lab 1 Due Wednesday, January 30, 2002Tomcat Installation, WAR Files and ServletsIn this lab we will be using an HTTP server called Tomcat available from the Jakarta Apache Project. In Part 1, we will present the details associated with the installation and basic configuration of Tomcat running under either Windows ’95 or Windows NT (you may also use Linux). In Part 2 we will experiment with WAR files, authentication and servlets. Because of few but occasional incompatibilities, let’s agree to use Netscape for browsing.Part I Installing Tomcat on Windows 95/Windows NT1) If you have not already done so, you need to install the Java programming language on your system. Obtain a copy of the JDK1.3.0 (Java 2 SDK) compiler. If you already have installed JDK1.2 then that will work fine. This compiler is available from Sun Microsystem’s web site at http://java.sun.com/j2se/1.3/download-windows.html. You should also download and install the Java documentation. This is available from Sun at http://java.sun.com/j2se/1.3/docs.html. Choose the Browse and Download documentation option and then download one large bundle in HTML format. These files arrive in a compressed format. You can use winzip to expand them. You can download an evaluation copy of winzip from http://www.winzip.com/winzip/download.html. Be sure to set your path variable (so that the Java compiler and Java interpreter can be run from any directory using simple commands). Also be sureto set your classpath variable (so that javac and java can find the locations of the classes that your programs will use). The following web site contains directions on how to set the path and classpath variables: http://java.sun.com/j2se/1.3/install-windows.html.2) Visit the Jakarta Project web site at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/. Choose jakarta-tomcat-4.0.1.zip from the left hand column. After downloading, use winzip to expand the file Jakarta-tomcat-4.0.1.zip to your C or D drive. This expansion will automatically create a directory called d:\jakarta-tomcat-4.0.1. (If you have chosen C the directory will be called c:\jakarta-tomcat-4.0.1.) Make sure that your classpath contains the dot “.”. Also, add the servlet.jar file to your classpath. My classpath includes the following line: D:\jakarta-tomcat-4.0.1\common\lib\servlet.jar. Also, ensure that you JAVA_HOME system variable is set to the location of the JDK. My JAVA_HOME variable is set to D:\jdk1.2.2 TESTING THE INSTALLATIONUsing the MyComputer icon, look over the files in the new directory. You should see a directory structure containing many files and subdirectories. Your path to the webapps directory should look like the following:D:\jakarta-tomcat-4.0.1\webappsThe following directions will assume that you have such a directory structure.3) After changing to the Jakarta directory with the command cd D:\jakarta-tomcat-4.0.1\bin, run the startup.bat batch file by typing startup. This should execute Tomcat in a new DOS window called Catalina.Starting service Tomcat-StandaloneApache Tomcat/4.0.1Starting service Tomcat-ApacheApache Tomcat/4.0.1195-733 Internet Technologies Carnegie Mellon University 4) Enter the following URL in Netscape http://localhost:8080/index.html. Your browser screen should display the Tomcat default screen. The html file that generates this screen can be found under D:\jakarta-tomcat-4.0.1\webapps\ROOT\index.html.5) The index.html file and its parent directory are contained in a directory structure similar to the one shown below (the ‘classes’ and ‘lib’ directories are not found under ‘webapps/ROOT’ but are typical of the web applications we will write): D:\Jakarta-tomcat-4.0.1 | conf | --- server.xml this is a serverwide configuration file | |webapps the directory holding web applications | ROOT a web application whose contents are publicly | accessible | --- index.html home page for this web application | WEB-INF contents not served directly to clients but | contains classes and configuration information ---web.xml deployment descriptor containing configuration | information for this web application | classes this directory contains servlet classes |--- someservlet.class | lib this directory holds classes held in jar files | --- my.jar 295-733 Internet Technologies Carnegie Mellon University Part II Building a Simple WAR File 1) One purpose of WAR (Web Application Archive) files is to make the distribution of web applications simpler. In what follows, I would like you to work under a directory structure away from Tomcat. After we have completed these steps, we will copy the resulting WAR file to Tomcat’s webapps directory. Let’s begin by creating a new directory called “simpleapp”. Under “simpleapp” create a new file called “index.html” as shown in Figure 1.1. Under the directory “simpleapp”, create another directory called “WEB-INF”. Within “WEB-INF”, create a directory called “classes”. Under the directory “classes”, create a servlet called HandleForm.java as shown in Figure 1.2. Compile this program with javac. Under the “WEB-INF” directory, create a deployment descriptor called web.xml as shown in Figure 1.3.<!-- index.html --><html><head><title>Introductions</title></head><body> <form method="get" action="processForm"> Hi, what is your name? <input type="text" name = "name"> <p> <input type = "submit"> </form></body></html>Figure 1.1395-733 Internet Technologies Carnegie Mellon University // HandleForm.java // An introductory servletimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class HandleForm extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { String name


View Full Document

CMU ISM 95733 - Lab 1

Download Lab 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?