Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing...

23
Chapter 1 Server Setup and Configuration

Transcript of Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing...

Page 1: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

Chapter 1

Server Setup and Configuration

Page 2: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

Contents

A. Installing and Configuring Web Server

B. Testing the Installation

Page 3: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

A. Installing and Configuring Web Server

1. Installing Java2. Installing Tomcat Web Server3. Configuring Tomcat

Page 4: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

1. Installing Java

Download JDK 6 Update 6 (jdk-6u6-windows-i586-p.exe) at http://java.sun.com/javase/downloads/index.jsp and run it

Page 5: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

2. Installing Tomcat Web Server

Download apache-tomcat-6.0.16.exe at http://tomcat.apache.org and run it Destination folder: C:\Program Files\Apache Software

Foundation\Tomcat 6.0 (TOMCAT_DIR)

Page 6: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3. Configuring Tomcat

Configuration file: TOMCAT_DIR/conf/server.xml

3.1. Specifying Server Port 3.2. Enabling Servlet Reloading

Page 7: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3.1. Specifying Server Port Change port from 8080 to 80

Change to 80

Page 8: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3.2. Enabling Servlet Reloading

Add DefaultContext:

Page 9: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

B. Testing the Installation

1. Starting Tomcat2. Testing HTML3. Testing JSP4. Testing Servlet

Page 10: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

1. Starting Tomcat

Start > All Programs > Apache Tomcat 6.0 > Monitor Tomcat

Right-click the Tomcat icon at the lower right corner of the screen > Start service

Page 11: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

2. Testing HTML

2.1. Preparing Hello.html2.2. Running Hello.html in Web

Browser

Page 12: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

2.1. Preparing Hello.html

Use Microsoft FrontPage or Dreamweaver 8 to edit and save Hello.html to TOMCAT_DIR/webapps/ROOT

Page 13: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

2.2. Running Hello.html in Web Browser

Page 14: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3. Testing JSP

3.1. Preparing Hello.jsp File3.2. Running Hello.jsp in Web

Browser

Page 15: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3.1. Preparing Hello.jsp File

Use Microsoft FrontPage or Dreamweaver 8 to edit and save Hello.jsp to TOMCAT_DIR/webapps/ROOT

Page 16: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

3.2. Running Hello.jsp in Web Browser

Page 17: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

4. Testing Servlet

4.1. Preparing HelloServlet4.2. Declaring HelloServlet in

web.xml4.3. Running HelloServlet in Web

Browser

Page 18: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

4.1. Preparing HelloServlet.java

Use Eclipse 3.2 to edit HelloServlet.java (see next slide) Import TOMCAT_DIR/lib/servlet-api.jar to

the Eclipse project Save HelloServlet.class to

TOMCAT_DIR/webapps/ROOT/WEB-INF/classes

Page 19: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.
Page 20: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

4.2. Declaring HelloServlet in web.xml

Using WordPad or Dreamweaver to add the following to TOMCAT_DIR/webapps/ROOT/WEB-INF/web.xml

Page 21: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

4.3. Running HelloServlet in Web Browser

Page 22: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

References

1. Core Servlets And Java Server Pages, Volume 1, 2nd Edition, Chapter 02.

Page 23: Chapter 1 Server Setup and Configuration. Contents A.Installing and Configuring Web Server B.Testing the Installation.

Revision History