Вы находитесь на странице: 1из 18

Chapter 4.

Server Side Technology


 Basic concept of web server,
 Introduction to web server side scripting,
 Difference between client side scripting and server
side scripting
 Introduction to Server side scripting technologies.(
ASP,CGI, Servlet, PHP, Database)

1
Web server:
 A web server is the combination of computer and the program installed
on it .
 Web server interacts with the client through a web browser.
 It delivers the web pages to the client and to an application by using the
web browser and the HTTP protocols.
 A web server works on a client server model .
 A computer connected to the Intranet for providing the services to a
small company or a departmental store may contain the HTTP server
(to access and store the web pages and files), SMTP server (to support
mail services), FTP server ( for files downloading). The computer
containing all the above servers is sometimes called the web server
 Every Web server has an IP address and possibly a domain name
 Thus a web server is a computer connected to the web (Internet) that makes
web pages available to the world
 Any computer can be turned into a Web server by installing server
software and connecting the machine to the Internet
2
Server Technology

3
Server-side scripting

 Server-side scripting is a web server technology in which a


user's request is fulfilled by running a script directly on the web
server to generate dynamic web pages.
 It is usually used to provide interactive web sites that interface to
databases or other data stores.
 This is different from client-side scripting where scripts are run
on the client(web browser), usually in JavaScript.
 The primary advantage to server-side scripting is the ability to
highly customize the response based on the user's
requirements, access rights, or queries into data stores.
 The server-side scripting is done before a page is downloaded on
the browser.
 PHP, ASP scripts are the examples of server-side technologies.

4
With server-side scripting, you can:
 Dynamically edit, change, or add any content of a Web
page
 Respond to user queries and form data
 Access databases and return the result to a browser
 Access files and return the result to a browser
 Transform XML data to HTML data and return the results
to a browser
 Customize a Web page to make it more useful for
individual users
 Provide security and access control to Web pages
 Tailor your output to different types of browsers

5
Examples
 SOME server-side scripting languages include:
 ASP/ASP.NET (*.asp/*.aspx)
 ColdFusion Markup Language (*.cfm)
 Java via JavaServer Pages (*.jsp)
 PHP (*.php)
 Perl (*.pl)
 Python (*.py)
 Ruby (*.rb)

6
Difference between server side and client side
scripting
 Server side:
 Scripts executed by the web server and processed by the
server is called server-side script
 Done in asp, jsp, php,ruby etc. and executed by server.
 Code is hidden as all the code is executed before the html
is sent to the browser.
 Browser independent; Load on server
 Valuable resources in the server is used.
 Can be used to access the local files, directories etc.

7
Difference between server side and client side scripting
 Client Side
 Scripts executed only by the browser without contacting the server is called
client-side script
 The scripting code is visible to the user and hence not secure
 Browser dependent.
 Burden in server is reduced.
 No resources of the server is used.
 Cannot be used to access local files, directories etc.
 No need of extra software.
 Client side Scripting is possible to be blocked , where as server side
scripting can't be blocked by the user , so if you validate using CLIENT
SIDE only , and client side scripting blocked then even validation can
not be done and directly even wrong data can be accepted and thus
makes a flaw in the system.
E.g. JavaScript, VBScript etc.
8
ASP (Active Server Pages)
 ASP stands for Active Server Pages
 ASP is a server-side scripting technology developed by Microsoft.
 ASP is a program that runs inside IIS (Internet Information Services)
 ASP is a standard component in Windows 95,98, 2000, and XP. It can
be activated on all computers running Windows.
 An ASP file can contain text, HTML, XML, and scripts
 Scripts in an ASP file are executed on the server
 An ASP file has the file extension ".asp“
 An ASP file normally contains HTML tags, just like an HTML file.
However, an ASP file can also contain server scripts, surrounded by the
delimiters <% and %>.
 When a browser requests an ASP file, IIS passes the request to the ASP
engine. The ASP engine reads the ASP file, line by line, and executes
the scripts in the file. Finally, the ASP file is returned to the browser as
plain HTML
9
PHP
 PHP stands for PHP: Hypertext Preprocessor
 PHP is a server-side scripting language, like ASP
 PHP is the widely-used, free, and efficient alternative to competitors
such as Microsoft's ASP.
 PHP is perfectly suited for Web development, and can be embedded
directly into the HTML code.
 PHP supports many databases, such as MySQL, Informix, Oracle,
Sybase, Solid, PostgreSQL, Generic ODBC, etc.
 PHP is an open source software
 PHP is free to download and use
 PHP files can contain text, HTML tags and scripts
 PHP files are returned to the browser as plain HTML
 PHP files have a file extension of ".php", ".php3", or ".phtml“
 A PHP scripting block always starts with <?php and ends with ?>.
 A PHP scripting block can be placed anywhere in the document.
10
CGI (Common Gateway Interfaces)
 The Common Gateway Interface (CGI) is a standard (protocol) for
providing an interface, or a gateway, between an information server and
an external process (that is, a process external to the server).
 The web server fetches the CGI script, activates it as a process, passing
to the process input data transmitted by the web client. The web script
executes and transmits its output to the web server, which returns the
web-script generated data as the body of a response to the web client.
 CGI scripts are executables that will execute on the server to produce
dynamic and interactive web pages.
 CGI is most common on Unix or Linux servers.

11
 An HTTP request may specify a CGI program, or CGI script.
 A CGI program can be written in:
 Programming languages: C. Ada, C++, Fortran; such a
program needs to be compiled to generate an
executable.
 Script languages such as Php, Perl, Tkl, cobra, such a
program, referred to as a CGI script, requires the
appropriate language interpreter to be present at the
server host.
 Commonly used for processing user input from HTML
forms, and subsequently composing a web page sent as
part of the server response.

12
 When a web server receives a request whose URI specifies a web
program, the web server initiates the execution of the web program.
 The web program formulates its output in HTML, which is sent to the
server and forwarded to the web client as the HTTP response.
 The basic Idea of CGI:

 Web server sends data to the CGI Program via:


 environment variables (DOCUMENT_ROOT , QUERY_STRING, HTTP_COOKIE etc.)
 command line
 standard input
13
CGI program
server host client host

CGI program HTTP server


HTTP client

request

response
Working Principle of CGI
 Common Gateway Interface (CGI) appeared as a "protocol" for
generating dynamic content on a web server.
 The process gets a little more complicated:
 The browser sends an HTTP GET or POST command to the web server
with the parameters, along with the path to the requested document
(which in this case is a CGI program, although the browser doesn't
know or care about this distinction).
 The web server notes that the requested document is a CGI program
rather than a static HTML document.
 The web server initializes certain environment variables with the
passed parameters, runs the CGI program in a newly-created OS
process, and the CGI program in turn produces an HTML document as
its output, making use of the parameters as necessary.
 The web server returns the generated HTML document to the browser,
passing along the header information as before.
Servlet
 A small Java program that runs on a server which receives a request
and generates a response based on that request
 a software developer may use a servlet to add dynamic content to a Web
server using the Java platform
 Servlets are the Java counterpart to non-Java dynamic Web content
technologies such as CGI and ASP.NET.
 The biggest difference between the two is that a Java applet is
persistent. This means that once it is started, it stays in memory and
can fulfill multiple requests. In contrast, a CGI program disappears
once it has fulfilled a request.
 The persistence of Java applets makes them faster because there's no
wasted time in setting up and tearing down the process.

16
Database
 When there is a need to store and retrieve information (user names, items in
stock etc.) a database will be used to contain the data.
 A database is a collection of information that is organized so that it can easily
be accessed, managed, and updated.
 Traditional databases are organized by fields, records, and files. A field is a
single piece of information; a record is one complete set of fields; and a file is a
collection of records. For example, a telephone book is analogous to a file. It
contains a list of records, each of which consists of three fields: name, address,
and telephone number.
 The most prevalent approach is the relational database, a tabular database
in which data is defined so that it can be reorganized and accessed in a number
of different ways.
 To access information from a database, you need a database management
system (DBMS). This is a collection of programs that enables you to enter,
organize, and select data in a database. (e.g. Oracle, MySQL, Ms Access etc.)
 Sever-side script can communicate to a database using a structured query
language (SQL) which manipulates the database (add, remove, update etc.)
17
Exercise
1. What is server side scripting and explain the concept
of web server.
2. Describe the differences between the client side
scripting and server side scripting.
3. Explain the different server side scripting
technologies such as PHP, ASP, CGI, Servlet etc.
4. What is CGI? Explain the working principle of CGI.
5. What is database? Explain why it is used in server
side scripting.
Note: Submit this assignment on next class.
18

Вам также может понравиться