Download Server-Side Programming - gozips.uakron.edu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Relational model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Transcript
2440: 141
Web Site Administration
Web Server-Side Programming
Professor: Enoch E. Damson
Programming Languages
 Programming languages are used to develop programs
that help:
 Input data
 Processes data
 Store data
 Output data
Web Server-Side Programming
2
Programming
 Programming is accomplished in two ways:
 Sequentially

Using variables and procedures/functions
 Object-Oriented

Using classes and objects which have:
 Attributes (variables)
 Methods (functions/procedures)
Web Server-Side Programming
3
Programs
 Programs are written to perform specific tasks
 Programming is accomplished using major elements such as:
 Syntax and Expressions
 Comments
 Literal Values
 Data Types and Variables
 Input/Output Data
 Arithmetic Operations
 Logical Operations


Selections/Decisions
Repetitions/Looping
 Arrays
Web Server-Side Programming
4
Web Programming Languages
 Web pages that contain only HTML/XHTML statements
are called static pages
 Web pages that contain programming statements are
known as dynamic pages (allow the content to change)
Web Server-Side Programming
5
Web Programming Languages…
 Programming languages can be used to create:
 Dynamic webpages on client Web browsers

Using client-side scripting languages such as JavaScript and
VBScript
 Dynamic webpages that run on Web servers and update
databases


Using server-side scripting languages such as Java Server Pages
(JSP), Active Server Pages (ASP), ASP,NET, PHP, Coldfusion, etc
Using SQL on DBMSs such as Oracle, MySQL, SQL Server, DB2, etc
Web Server-Side Programming
6
Server-Side Programming
 Server-side programs provide dynamic content and
allows interaction with Web users using:
 DHTML
 Active Server Pages (ASP)
 Servlets and Java Server Pages (JSP)
 PHP: Hypertext Preprocessor (PHP)
 Practical Extraction and Reporting Language (Perl)
 Databases
Web Server-Side Programming
7
Dynamic Documents
 Dynamic HTML (DHTML) is a term for a combination
of client-side technologies that produce dynamic
documents
 DHTML can be used to create simple animations,
images, and text with resources such as:
 HTML/XHTML
 Style sheets (CSS)
 Client-side scripting (JavaScript or VBScript)
Web Server-Side Programming
8
Web Applications
 Web applications use a combination of the following
 HTML/XHTML
 Style sheets (CSS)
 Client-side scripting languages
 such as JavaScript or VBScript
 Server-side scripting languages
 Such as ASP, ASP.NET, PHP, JSP, etc
 Database Management Systems (DBMS) to create and
manipulate databases

Usually using the embedded Structured Query Language (SQL)
especially in Relational Databases.
Web Server-Side Programming
9
HTML Form Page
<html>
<head>
<title>HTML Form Page</title>
</head>
<body>
<form action=“http://localhost/cgi-bin/perl/hello.cgi”
method=“post”>
7.
<input name=“firstname” type=“text” />
8.
<input value=“Send” type=“submit” />
9.
</form>
10. </body>
11. </html>
1.
2.
3.
4.
5.
6.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Web Server-Side Programming
Opening <html> tag
Opening <head> tag
Specifying the title of the page (HTML Form
Page) with the two-sided <title> tag
Closing </head> tag
Opening <body> tag
Opening <form> tag specifying the recipient
CGI file using the action attribute and the
method of sending data (using the HTTP’s
post) with the method attribute
Using the <input> tag’s type attribute to
specify the form component (text for textbox)
being used to accept data, and the name
attribute to uniquely identify the component
Using the <input> tag’s type attribute to
specify a submit button (submit) being used
to send data, and the value attribute for the
button’s caption
Closing </form> tag
Closing </body> tag
Closing </html> tag
10
DHTML Sample Code
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
<html>
<head>
<script type = "text/javascript">
document.writeln("Hello World");
</script>
<style type=“text/css”>
p {color: blue}
</style>
<title>DHTML Page</title>
</head>
<body>
<p> Embedded style </p>
<p style="color: red"> Inline style </p>
</body>
</html>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
Web Server-Side Programming
Opening <html> tag
Opening <head> tag
Opening <script> tag specifying the script
language of choice (JavaScript)
Displays text (“Hello World”) on a browser
Closing </script> tag
Opening <style> tag specifying the style sheet
type (css – cascading style sheet)
Specifying a value of blue as the text color for
all paragraphs on the page – Embedded style
Closing </script> tag
Specifying the title of the page (DHTML Page)
with the two-sided <title> tag
Closing </head> tag
Opening <body> tag
Displays a paragraph on the page
Displays a paragraph with an Inline style
Closing </body> tag
Closing </html> tag
11
Active Server Pages (ASP)
 Microsoft’s server-side technology for creating
dynamic Web pages
 Based on Microsoft’s Component Object Model
(COM) and ActiveX Controls
 COM is a Microsoft standard that defines how software
components from different vendors can work together
 ActiveX controls are components built using the COM
specifications
 VBScript and JavaScript are the most popular ASP
languages but any language (such as C++, Perl, Java)
that supports COM can also be used
Web Server-Side Programming
12
ASP Page
1.
2.
3.
4.
<%@ language=“Javascript”>
<html>
<%= “Hello World” %>
</html>
1.
2.
3.
4.
Web Server-Side Programming
Specifies the ASP script language using
the @ directive
Opening <html> tag
Displays text on a page using the =
directive
Closing </html> tag
13
Servlets and Java Server Pages (JSP)
 Sun Microsystem’s alternative to Microsoft’s ASP
 Rely on Sun’s Java programming language
 Java – a portable object-oriented language
 Servlets – are server-side programs like CGI programs but
run as part of the Web server instead of executing as
separate processes (as CGI scripts do)
 JSP – provides the same benefits of servlets along with the
benefits of SSI
 JavaBeans – a component model written in Java to allow
developers write reusable components

JSP’s solution to separate content from presentation
Web Server-Side Programming
14
JSP Page
1.
2.
3.
<html>
<%= “Hello World” %>
</html>
1.
2.
3.
Web Server-Side Programming
Opening <html> tag
Displays text on a page using the =
directive
Closing </html> tag
15
Perl CGI Script
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
#!/cgi-bin/perl
#hello.cgi – Sample perl script
print “Content-type: text/html\n\n”;
use CGI qw(:standard);
use strict;
my ($fname);
$fname = param(‘firstname’);
print “<HTML\n”;
print “<head><title>Perl CGI
Script</title></head>\n”;
print “<body>Hello $fname</body>\n”;
print “</html>\n”;
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Web Server-Side Programming
Location of the Perl interpreter (required in
UNIX; optional in Windows)
Comment (non-executable statement)
Sends an HTML document type (text/html) to
the browser using the HTTP header line
(Content-type) and creates a new line
Allows the script to parse data from the form
when received
Prevents Perl from using undeclared variables
Declares a scalar variable (preceded by a $
sign) named fname
Assigns a form data to a variable
Sends the opening <html> tag to the browser
Sends the two-sided <head> and <title> tags
to the browser
Sends the two-sided <body> and contents of
the page to the browser
Sends the closing </html> tag to the browser
16
PHP: Hypertext Preprocessor (PHP)
 A simple open-source server-side programming language
used for developing interactive Web documents
 Includes object-oriented programming (OOP) capabilities
Web Server-Side Programming
17
PHP Page
1.
2.
3.
<html>
<?php echo “Hello World” ?>
</html>
1.
2.
3.
Web Server-Side Programming
Opening <html> tag
Displays text on a browser
Closing </html> tag
18
Databases
 Databases are a collection of data and metadata
(data about other data) about entities using a
database management system (DBMS)
 DBMS – software used to create, construct and manipulate
databases

E.g. Oracle, Microsoft SQL Server, MySQL, etc
 Entities – any thing, place, event, etc that data is collected
about

Data is collected in the form of attributes to help make up records


Attributes – description of an entity
Records – collection of attributes
Web Server-Side Programming
19
DBMS
 Most DBMSs use a data definition language (DDL) and
data manipulation language (DML) to help create and
manipulate databases
 The most widely used DDL/DML for databases is the
structured query language (SQL) – pronounced “sequel”
 Used by virtually all DBMSs
Web Server-Side Programming
20
SQL
 SQL is a language embedded in virtually all DBMSs to
perform several tasks including:
 Creating the structure of database objects

Using the create command
 Removing database objects

Using the drop command
 Changing the structure of database objects

Using the alter command
Web Server-Side Programming
21
SQL…
 Other SQL functionalities include:
 Adding records into database tables

Using the insert command
 Removing records from database tables

Using the delete command
 Changing records in database tables

Using the update command
 Retrieve records from database tables

Using the select command
Web Server-Side Programming
22
Web Servers and Server-Side
Programming Language
 Choosing a programming language for server-side
programming depends on the type of Web server to use
and vice versa
 The two most popular Web servers allows you to choose
their most friendliest programming language
 IIS is most friendly with ASP, ASP.NET
 Apache is most friendly with PHP, JSP, etc
Web Server-Side Programming
23