chp18_final - Mastering the Internet, XHTML, and JavaScript...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Mastering the Internet, XHTML, and JavaScript Chapter 18 Server-side Scripting Outline Goals and Objectives Chapter Headlines Introduction Client/Server Architecture Basics of CGI Scripting Universal CGI Scripts Web Servers Apache Servers Tomcat Servers Summary Chapter 18 - Server-side Scripting 2 Goals Goals and Objectives Understand data communication between clients and servers, CGI protocol, name/value pairs, pairs encoding and decoding, processing form data, and installing and using Apache and Tomcat servers Objectives Processing web page data Client/Server architecture Basics of CGI protocol and scripting Structure of CGI scripts Standard environment variables Output structure Web severs Apache and Tomcat servers Chapter 18 - Server-side Scripting 3 Chapter Headlines 18.1 Introduction CGI protocol solves the intriguing puzzle of the server side 18.2 Client/Server Architecture Adding a computer adds a tier to the architecture 18.3 Basics of CGI Scripting The processing of name/value pairs begins here 18.4 Universal CGI Scripts Write a program once and use it in any web page 18.5 Web Servers Learn the different types of web servers 18.6 Apache Servers It is time to run your own HTTP server 18.7 Tomcat Server Interested in Java servlets, JSPs; Tomcat is ready to serve Chapter 18 - Server-side Scripting 4 Introduction CGI facilitates the communication between client and server The server hosts the website and web pages CGI scripts send back web pages, files, MIME documents It incorporates interactivity to web pages CGI script is a computer program to process data and input of an interactive element in a web page The three main functions are: Parse and decode the name/value pairs and extract the data Make a decision based on the data Send back a response to the surfer based on its data processing CGI script can be written in any programming language Chapter 18 - Server-side Scripting 5 Introduction Chapter 18 - Server-side Scripting 6 There are three types of Client/Server architectures: Single tier Two tier Three tier Client/Server Architecture They all access a database on the server using CGI script In a single tier model, database and application reside on the same computer In a two tier model, database resides on the server and the application resides on the client In a three tier model, a middle layer separates the database from the application Chapter 18 - Server-side Scripting 7 Client/Server Architecture Chapter 18 - Server-side Scripting 8 CGI scripts follow a certain structure, perform certain tasks and use certain environment variables General structure of a CGI script has three main parts: Basics of CGI Scripting Part 1 receive, check, parse name/value pairs Part 2 decode name/value pairs and extract data Part 3 prepares the output to be sent back Initialization Set initial values of variables and read input Parsing Separate name/value pairs and isolate them Decoding Extract values of the names Output Prepare output based on the decision taken Server identify server parameters Request hold information in a request Client have all the information about the client Chapter 18 - Server-side Scripting The four tasks of a CGI script are: There are three groups of environment variables: 9 Universal CGI Scripts We can write a script once and use it in many web pages Examples of scripts that can be used and reused are: Script for parsing and decoding name/value pairs Page hit counters Sending of automatic e-mails Chapter 18 - Server-side Scripting 10 There are HTTP, e-mail, newsgroup, application, proxy, FTP, and Telnet Servers Each type of server uses a corresponding protocol HTTP servers are most common and serve websites A server hosts a database and responds to clients requests A web server runs on a stand-alone dedicated computer Web servers typically house and run CGI scripts from a cgi-bin directory Some web servers are free and some charge a fee The servers have to be maintained and backed up A server should be able to efficiently handle peak load Chapter 18 - Server-side Scripting 11 Web Servers Apache server is the most widely used web server It offers a customizable approach to web servers The latest version can be downloaded from http://www.apache.org The installation procedure is easy Three folders of interest to the users are Apache Server cgi-bin holds CGI scripts htdocs holds HTML files conf has the configuration files Running Apache opens a DOS window and then leaves no visible sign that Apache is running The server must be stopped by clicking on the appropriate file Chapter 18 - Server-side Scripting 12 Example 18.1: Use Apache server to run a CGI script Apache Server Chapter 18 - Server-side Scripting 13 Tomcat is another Apache group server to render JSPs, servlets, and web pages with XHTML code only The latest version can be downloaded from http://www.apache.org The installation procedure is simple Two folders of interest to users are: Tomcat Server webapps to run JSPs conf has the configuration files Setting JAVA_HOME system variable Setting current directory to Tomcat bin directory Startin Tomcat Server Loading up a test web page Chapter 18 - Server-side Scripting 14 Tomcat can be ran in windows by Tomcat Server Chapter 18 - Server-side Scripting 15 Example 18.2: Use Tomcat server to run a web page Tomcat Server Chapter 18 - Server-side Scripting 16 Summary CGI protocol allows client/server communication There are 3 client/server architecture models CGI scripts have a basic structure and perform some tasks CGI scripts can be written once and used in many web pages There are many types of web servers Apache server is the most widely used web server Tomcat server is another useful server Chapter 18 - Server-side Scripting 17 ...
View Full Document

This note was uploaded on 07/01/2011 for the course COMP 103 taught by Professor Mulhimaldoori during the Spring '11 term at American Dubai.

Ask a homework question - tutors are online