ࡱ > " [@ / bjbj44 :4 Vi Vi 8 t Z | " : " > > > } } } x| z| z| z| ; | Ղ $ R ] y } > > ; V u* u* u* > > x| u* x| u* u* * v Rq @ y > 0i - u | { l 0 nv L ' y " y y } > , u* $ v } } } ć ʐ n Y* ʐ 95-702 Organizational Communication and Distributed Object Technologies Homework 1 Due Tuesday September 20, 2005 Topics: Distributed Systems, Tomcat, Xalan and Axis installation, Servlets, Log Files, SAX Event Handling, RSS news feeds Part I Installing and Testing Course Software 1. Download and install J2SE 5 a. Visit www.javasoft.com. b. Select J2SE Core Desktop, popular Downloads J2SE 5.0, and download JDK 5.0 Update 5. c. Visit http://java.sun.com/j2se/1.5.0/install-windows.html and follow the instructions to set your path variable. Mine reads C:\Program Files\Java\jdk1.5.0_05\bin. d. Test JDK5.0 Runtime: Open a DOS prompt and check the version as shown below. C:>java -version java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing) e. Test JDK5.0 compiler: C:\Documents and Settings\mm6>javac -version javac 1.5.0_05 javac: no source files f. Be sure to download and unzip the java documentation from Sun. 2. Download and Install Xalan (for XSLT) from Apache a. Visit http://apache.cs.utah.edu/xml/xalan-j/ and download xalan-j_2_7_0-bin.zip. b. I unzipped mine to C:\xalan. c. Create a user variable (Start/Settings/Control panel/System/Advanced/Environment Variables) called XLANCLASSPATH with the following value (a single string separated by semicolons): C:\xalan\xalan-j_2_7_0\xalan.jar; C:\xalan\xalan-j_2_7_0\xercesImpl.jar; C:\xalan\xalan-j_2_7_0\xml-apis.jar d. Create another user variable called CLASSPATH and set it to %XLANCLASSPATH%. That is, dereference the variable you defined in part c. Create a batch file (with notepad) called xalan.bat with the following single line: java org.apache.xalan.xslt.Process -IN %1 -XSL %2 -OUT %3 Save this file to C:\batch\xalan.bat. f. Place "C:\batch" in your path variable. Mine now reads: C:\Program Files\Java\jdk1.5.0_05\bin;C:\batch g. Test by typing xalan at any DOS command prompt C:>xalan C:>java org.apache.xalan.xslt.Process -IN -XSL -OUT Missing argument for option: -IN Missing argument for option: -XSL Missing argument for option: -OUT 3. Download and install Apache Tomcat a. Visit http://tomcat.apache.org/ and select Windows Executable from the core Binary Distributions apache-tomcat-5.5.12.exe b. I included all features. Be sure to remember the user name and password of the Tomcat administrator. c. I installed mine at C:\Tomcat5.5. Add a user environment variable called CATALINA_HOME with the path pointing to Tomcat. My CATALINA_HOME reads C:\Tomcat 5.5 e. Testing Tomcat: First, place Tomcat's bin directory in your path. Mine now reads C:\Program Files\Java\jdk1.5.0_05\bin;C:\batch; C:\Tomcat 5.5\bin. From any DOS prompt type tomcat5w. If Tomcat is started stop it. If Tomcat is stopped start it. Start Tomcat with tomcat5w and visit http://localhost:8080. 4. Download and Install Apache Axis a. Download activation.jar from http://java.sun.com/products/javabeans/glasgow/jaf.html b. Download mail.jar from http://java.sun.com/products/javamail/downloads/index.html c. Download xml-security-bin-1_2_1.zip from http://xml.apache.org/security/dist/java-library/ d. Download and unzip axis-bin-1_3.zip from HYPERLINK "http://ws.apache.org/axis/" http://ws.apache.org/axis/ e. Place Axis behind Tomcat. Copy the directory C:\Axis\axis-1_3\webapps\axis to C:\Tomcat 5.5\webapps f. Copy tools.jar, xmlsec-1.2.1.jar, activation.jar and mail.jar to the C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\ directory. g. Create a user variable called AXISCLASSPATH and set it to the following(a single string separated by semicolons): C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis-ant.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis-schema.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\jaxrpc.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\log4j.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\saaj.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\mail.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\activation.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\xmlsec-1.2.1.jar; C:\Tomcat 5.5\webapps\axis\WEB-INF\lib\tools.jar h. Add %AXISCLASSPATH% to your classpath variable. Mine reads %XALANCLASSPATH%;%AXISCLASSPATH% i. Test Axis Start Tomcat with the axis directory already present under C:\Tomcat 5.5\webapps Visit http://localhost:8080/axis The Axis happiness should report that all needed and optional components are found. You should be able to view two services and their WSDL. 5. Download and install Apache Ant a. Visit http://ant.apache.org/, download and unzip Ant 1.6.5 b. Add the two environment variables JAVA_HOME and ANT_HOME My variables read JAVA_HOME C:\Program Files\Java\jdk1.5.0_05 ANT_HOME C:\ApacheAnt\apache-ant-1.6.5 c. Add a pointer to ant in your path variable. Mine now reads: C:\Program Files\Java\jdk1.5.0_05\bin;C:\batch; C:\Tomcat 5.5\bin;%ANT_HOME%\bin c. Test Ant with C:\Documents and Settings\mm6>ant Buildfile: build.xml does not exist! Build failed d. Copy "server/lib/catalina-ant.jar" from the Tomcat installation to the "lib" directory of your Ant installation. Part II Building a Web Application In what follows, we will work under a directory structure away from the Tomcat installation. Lets begin by creating a new directory called ANewApp. Under AnewApp, create the following directories: docs, src, and web. Under AnewApp/web create a new file called index.html as shown in Figure 1.1. Under the directory AnewApp/web, create another directory called WEB-INF. Note that WEB-INF must be in caps even though it will not appear to be entirely in upper case in some displays. Within the AnewApp/src directory, create a servlet called HandleForm.java as shown in Figure 1.2. Under the web/WEB-INF directory, create a deployment descriptor called web.xml as shown in Figure 1.3.