2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
-
Upload
baldwin-short -
Category
Documents
-
view
223 -
download
0
Transcript of 2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
The University of AkronCollege of Applied Science & Technology
Dept. of Business & Information Technology
2440: 141Web Site Administration
Web Server-Side ProgrammingProfessor: Enoch E. Damson
Programming LanguagesProgramming languages are used to develop programs
that help:Input dataProcesses dataStore dataOutput data
Web Server-Side Programming 2
ProgrammingProgramming 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
ProgramsPrograms are written to perform specific tasksProgramming is accomplished using major elements such as:
Syntax and ExpressionsCommentsLiteral ValuesData Types and Variables Input/Output DataArithmetic OperationsLogical Operations
Selections/Decisions Repetitions/Looping
Arrays
Web Server-Side Programming 4
Web Programming LanguagesWeb pages that contain only HTML/XHTML statements
are called static pagesWeb 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
VBScriptDynamic 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 ProgrammingServer-side programs provide dynamic content and
allows interaction with Web users using:DHTMLActive 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 DocumentsDynamic 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/XHTMLStyle sheets (CSS)Client-side scripting (JavaScript or VBScript)
Web Server-Side Programming 8
Web ApplicationsWeb applications use a combination of the following
HTML/XHTMLStyle sheets (CSS)Client-side scripting languages
such as JavaScript or VBScriptServer-side scripting languages
Such as ASP, ASP.NET, PHP, JSP, etcDatabase 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 Page1. <html>2. <head>3. <title>HTML Form Page</title>4. </head>5. <body>6. <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. Opening <html> tag2. Opening <head> tag3. Specifying the title of the page (HTML Form
Page) with the two-sided <title> tag4. Closing </head> tag5. Opening <body> tag6. 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
7. 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
8. 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
9. Closing </form> tag10. Closing </body> tag11. Closing </html> tag
Web Server-Side Programming 10
DHTML Sample Code1. <html>2. <head>3. <script type = "text/javascript">4. document.writeln("Hello World");5. </script>6. <style type=“text/css”>7. p {color: blue} 8. </style>9. <title>DHTML Page</title>10. </head>11. <body>12. <p> Embedded style </p>13. <p style="color: red"> Inline style </p>14. </body>15. </html>
1. Opening <html> tag2. Opening <head> tag3. Opening <script> tag specifying the script
language of choice (JavaScript)4. Displays text (“Hello World”) on a browser5. Closing </script> tag6. Opening <style> tag specifying the style sheet
type (css – cascading style sheet)7. Specifying a value of blue as the text color for
all paragraphs on the page – Embedded style8. Closing </script> tag9. Specifying the title of the page (DHTML Page)
with the two-sided <title> tag10. Closing </head> tag11. Opening <body> tag12. Displays a paragraph on the page13. Displays a paragraph with an Inline style14. Closing </body> tag15. Closing </html> tag
Web Server-Side Programming 11
Active Server Pages (ASP)Microsoft’s server-side technology for creating
dynamic Web pagesBased on Microsoft’s Component Object Model
(COM) and ActiveX ControlsCOM is a Microsoft standard that defines how software
components from different vendors can work togetherActiveX controls are components built using the COM
specificationsVBScript 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 Page1. <%@ language=“Javascript”>2. <html>3. <%= “Hello World” %>4. </html>
1. Specifies the ASP script language using the @ directive
2. Opening <html> tag3. Displays text on a page using the =
directive4. Closing </html> tag
Web Server-Side Programming 13
Servlets and Java Server Pages (JSP)Sun Microsystem’s alternative to Microsoft’s ASPRely on Sun’s Java programming language
Java – a portable object-oriented languageServlets – 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 Page1. <html>2. <%= “Hello World” %>3. </html>
1. Opening <html> tag2. Displays text on a page using the =
directive3. Closing </html> tag
Web Server-Side Programming 15
Perl CGI Script1. #!/cgi-bin/perl2. #hello.cgi – Sample perl script3. print “Content-type: text/html\n\n”;4. use CGI qw(:standard);5. use strict;6. my ($fname);7. $fname = param(‘firstname’);8. print “<HTML\n”;9. print “<head><title>Perl CGI
Script</title></head>\n”;10. print “<body>Hello $fname</body>\n”;11. print “</html>\n”;
1. Location of the Perl interpreter (required in UNIX; optional in Windows)
2. Comment (non-executable statement)3. Sends an HTML document type (text/html) to
the browser using the HTTP header line (Content-type) and creates a new line
4. Allows the script to parse data from the form when received
5. Prevents Perl from using undeclared variables6. Declares a scalar variable (preceded by a $
sign) named fname 7. Assigns a form data to a variable8. Sends the opening <html> tag to the browser9. Sends the two-sided <head> and <title> tags
to the browser10. Sends the two-sided <body> and contents of
the page to the browser11. Sends the closing </html> tag to the browser
Web Server-Side Programming 16
PHP: Hypertext Preprocessor (PHP)A simple open-source server-side programming language
used for developing interactive Web documentsIncludes object-oriented programming (OOP) capabilities
Web Server-Side Programming 17
PHP Page1. <html>2. <?php echo “Hello World” ?>3. </html>
1. Opening <html> tag2. Displays text on a browser3. Closing </html> tag
Web Server-Side Programming 18
DatabasesDatabases 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
DBMSMost 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
SQLSQL is a language embedded in virtually all DBMSs to
perform several tasks including:Creating the structure of database objects
Using the create commandRemoving 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 LanguageChoosing 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 languageIIS is most friendly with ASP, ASP.NETApache is most friendly with PHP, JSP, etc
Web Server-Side Programming 23