230 likes | 244 Views
Learn about web server side programming and how to create dynamic web applications using programming languages such as JavaScript, VBScript, JSP, and ASP. Explore topics such as input/output data, programming elements, server-side scripting, dynamic HTML, and database management systems.
E N D
The University of AkronSummit CollegeBusiness Technology Dept. 2440: 141Web Site Administration Web Server-Side Programming Instructor: 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
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
Programs • Programs are written to perform specific tasks • Programming is accomplished using major elements such as: • Comments • Constant values • Variables and Data types • Input/OutputData • Arithmetic Operations • Logical Operations • Selections/Decisions • Repetitions/Looping • Arrays Web Server-Side Programming
Web Programming Languages • Web pages that contain only HTML/XHTML statements are called static pages • Pages that contain programming statements are known as dynamic pages (allow the content to change) Web Server-Side Programming
Web Programming Languages… • Programming languages can be used to create: • Dynamic pages on client Web browsers • Using client-side scripting languages such as JavaScript and VBScript • Dynamic pages 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 Web Server-Side Programming
Server-Side Programming • Server-side programs provide dynamic content and allows interaction with Web users using: • Web Forms • 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
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
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
DHTML Sample Code • <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> • 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 Web Server-Side Programming
HTML Form Page • <html> • <head> • <title>HTML Form Page</title> • </head> • <body> • <form action=“http://localhost/cgi-bin/perl/hello.cgi” method=“post”> • <input name=“firstname” type=“text” /> • <input value=“Send” type=“submit” /> • </form> • </body> • </html> • 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 Web Server-Side Programming
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
ASP Page • <%@ language=“Javascript”> • <html> • <%= “Hello World” %> • </html> • Specifies the ASP script language using the @ directive • Opening <html> tag • Displays text on a page using the = directive • Closing </html> tag Web Server-Side Programming
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
JSP Page • <html> • <%= “Hello World” %> • </html> • Opening <html> tag • Displays text on a page using the = directive • Closing </html> tag Web Server-Side Programming
Perl CGI Script • #!/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”; • 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 Web Server-Side Programming
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
PHP Page • <html> • <?php echo “Hello World” ?> • </html> • Opening <html> tag • Displays text on a browser • Closing </html> tag Web Server-Side Programming
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
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
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
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
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