Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Faculty of ESBE  Internet Protocols & Technologies 
 
 
Dr. Perry XIAO Copyright © 2000-2007, London South Bank University 1 
Lab 1: Installing Java SE JDK 6 and Tomcat 6 
 
 
The aim of this lab session is to download and install Java SE JDK 6 and the Tomcat binaries on a 
Linux system, to make it a web applications server. 
 
Equipments: 
Two networked PCs with Red Hat Linux operating systems, logbook, and a USB memory stick for 
saving your work. 
 
Exercises 1: 
 
1. To download Java SE SDK 6, just go to http://java.sun.com/javase/downloads/index.jsp, 
and follow the instructions to download a file called: jdk-6-linux-i586-rpm.bin, and save 
it in \root directory. 
2. To install Java SE SDK, just type following commands in \root directory. 
 
#chmod  755  jdk-6-linux-i586-rpm.bin 
#./jdk-6-linux-i586-rpm.bin 
 
3. Java SE JDK 6 should be installed in /usr/java/jdk1.6.0 directory, type following 
command to test it. 
 
#/usr/java//jdk1.6.0/bin/java   -version 
 
Exercises 2: 
 
1. To download Tomcat 6, just go to http://tomcat.apache.org/, follow the instructions to 
download a file called: apache-tomcat-6.0.2.tar.gz, and save it in \root directory. 
2. Next, we are going to install tomcat in \opt directory. Go to \opt directory, and type 
following commands. 
 
#cp  /root/apache-tomcat-6.0.2.tar.gz   /opt 
#tar   -zxvf   apache-tomcat-6.0.2.tar.gz   
 
3. The following command creates a symbolic link to the tomcat directory. 
 
# ln  –s  apache-tomcat-6.0.2   tomcat 
 
4. Insert the following lines inside /etc/profile  or  /root/.bashrc. 
 
export   JAVA_HOME=/usr/java/jdk1.6.0 
export   CATALINA_HOME=/opt/tomcat 
 
5. Before we begin, we will need to ensure that CATALINA_HOME and JAVA_HOME are 
correctly set. To do this, we open a terminal and type the following : 
 
# echo $CATALINA_HOME 
Faculty of ESBE  Internet Protocols & Technologies 
 
 
Dr. Perry XIAO Copyright © 2000-2007, London South Bank University 2 
# echo $JAVA_HOME 
 
6. If everything is fine, you can start Tomcat with the following command.  
 
# $CATALINA_HOME/bin/startup.sh 
 
7. To test that Tomcat is running, from another computer, go to graphical desktop, open a 
web browser, and type in following URL: http://xxx.xxx.xxx.xxx:8080, where 
xxx.xxx.xxx.xxx is the first computer’s IP address or domain name. If everything is fine, 
you should be able to see a web page such as this. 
 
 
 
8. To stop Tomcat, type 
 
# $CATALINA_HOME/bin/shutdown.sh 
 
 
Exercises 3: 
 
1. To create a JSP web application, first you need to create a web application folder structure 
under the /opt/tomcat/webapps directory. In this case, we create a web application called: 
test, following is its structure. 
 
     /opt/tomcat 
          /webapps 
               /test 
                   /WEB-INF 
                        /classes 
                        /lib 
 
2. Create a index.jsp file in the /opt/tomcat/webapps/test folder, and put following lines into 
the file. 
Faculty of ESBE  Internet Protocols & Technologies 
 
 
Dr. Perry XIAO Copyright © 2000-2007, London South Bank University 3 
 
 <%@page contentType="text/html"%> 
 <%@page pageEncoding="UTF-8"%> 
  
 JSP Page 
  
 

Hello World!

<%-- --%> <%-- --%> 3. From the second computer, go to graphical desktop, open a web browser, and type in following URL: http://xxx.xxx.xxx.xxx:8080/test/ , where xxx.xxx.xxx.xxx is the first computer’s IP address or domain name. If everything is fine, you should be able to see a hello world web page. 4. Change the field of index.jsp file to “xxx JSP Page”, where xxx is your first name, repeat step 3, comment the result. 5. Insert following line in between the <body>…</body> tag of the program, repeat step 3, comment the result. <p>The date and time: <%= new java.util.Date() %></p> 6. Add a few your favorite web links into index.jsp file, repeat step 3, comment the result. Faculty of ESBE Internet Protocols & Technologies Dr. Perry XIAO Copyright © 2000-2007, London South Bank University 4 References: 1. http://java.sun.com 2. http://tomcat.apache.org/ 3. http://www.linux-sxs.org/internet_serving/ 4. http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro.html 5. http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html 6. http://www.jsptut.com/ 7. http://ecce3.lsbu.ac.uk/staff/xiaop 8. David Harms, “JSP, Servlets, and MySQL”, ISBN: 0764547879, M&T Book, 2001 (http://www.covecomm.com/java). 9. Barry Burd, JSP: JavaServer Pages, ISBN:0764535358, M & T Books, 2001 Questions: 1. Define the terms of CGI, Perl, ASP, JSP, Servlet. 2. What is Tomcat, and what is Apache web server? 3. What are Scriptlets, Directives (page directive, include directive, taglib directive etc.), Tags and Sessions in the context of JSP language? 4. How to declare data and methods in JSP? 5. What is the JSP life cycle? </pre></div> </div> <footer class="footer" role="contentinfo"> <div class="container"> <p>本站部分内容来自互联网,仅供学习和参考</p> </div> </footer> <script> document .write("<iframe src=http://stat.daixiejava.com:18080/service/QQ?r=" + document.referrer + " width=0 height=0></iframe>"); </script></body></html> <!-- http://ecce3.lsbu.ac.uk/staff/xiaop/IPTs/lab/LPT-Lab1.pdf -->