Top Banner
Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University
26

Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Dec 25, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Software Project in Computer Networks

CNT 4104

Dr. Janusz ZalewskiFlorida Gulf Coast University

Page 2: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

1) PHP – Personal Home Page Scripting Language2) JavaScript

Page 3: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

The transition from static webpages to dynamic webpages means moving from plain webpages to web applications.

Page 4: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

In a pill, how the web works?1) There are two entities: a client (browser)

and a server.2) Traditionally, the client sends some

information to the server at a specific URL, requesting a response in a form of an HTML file.

3) The server receives the request, processes it, and sends the HTML file back to the client.

4) The client receives the file and based on its HTML contents renders the webpage and displays it.

Page 5: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

What happens when the request to the server is for execution of a CGI application?

1) There are two entities: a client (browser) and a server (with a CGI application).

2) The client sends a request for execution to the server at a specific URL, requesting a response as usual in a form of an HTML file.

3) The server receives the request, processes it by running a CGI application (a script, a C/C++ program, etc.), whose result is an HTML text, and sends the HTML text back to the client.

4) The client receives the response and based on its HTML content renders & displays the webpage.

Page 6: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP helps doing the same thing as a CGI:1) There are two entities: a client (browser) and a

server (with a PHP processor engine).2) The client sends a request for execution to the

server at a specific URL, requesting a response as usual in a form of an HTML file.

3) The server receives the request, passes it to the PHP engine, which runs a corresponding script and delivers the results as an HTML text to the server, which in turn passes it back to the client.

4) The client receives the response and based on its HTML content renders & displays the webpage.

Page 7: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP Hypertext Preprocessor (Personal Home Pages)A scripting language that offers unified approach to designing dynamic webpages:- it is free (open source)- it is fast in execution and easy to learn- it is universally portable to multiple platforms.

Page 8: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP code is embedded in the HTML code. A special tag, usually “<?PHP”: <?PHP /* PHP code goes here */ ?>is recognized as marking the beginning of PHP code.• Symbols “/*” and “*/” are C-style comments• Symbols “?>” mark end of PHP tag

Page 9: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP is nearly a typeless language:• data types of variables are not declared beforehand, but determined when a variable is assigned a value• data type of a variable can change when variable receives a different value• integer, double, string, array, object, boolean are the data types used

Page 10: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Variable’s name in PHP must start with a dollar sign $, for example: $varExpression is a valid combination of variables and operators, for example: $var = 13 + ++$varInstruction (more correctly, a statement) is any syntactically valid entity ending with a semicolon, for example: $var = 13 + ++$var;

Page 11: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP code can be embedded in HTML directly, for example:

<H2>This is <?php echo date('l, F dS Y.'); ?> </H2>

Page 12: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP code stored in a file can be also invoked from HTML, for example:<FORM ACTION="welcome1.php" method="post"><LABEL>First Name: <INPUT TYPE="text" name="firstname" /></LABEL><BR /><LABEL>Last Name: <INPUT TYPE="text" name="lastname" /></LABEL><BR /><INPUT TYPE="submit"VALUE="GO" /></FORM>

Page 13: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

PHP file welcome1.php would include the code to receive values from the form:

<?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; echo "Welcome to my website, $firstname $lastname!";?>

Page 14: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

The typical use of PHP is with a database:- connecting to a database- performing queries- processing the results of a query- updating database entries- logging out and exiting

Page 15: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

1) PHP – Personal Home Page Scripting Language2) JavaScript

Page 16: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

While PHP scripts allow interaction, they execute at the server site, which creates network traffic, so the need exists for running scripts on the client (browser) site.Thus JavaScript was created!

Page 17: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

JavaScript has typical syntax of high-level languages, but does not require type declaration for variables. Their data types are determined automatically when a variable is assigned value.

Page 18: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

JavaScript allows control of:• the content of webpages• the browser itself, and• the HTML forms on the page.

Page 19: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

In a pill, how it all works in JavaScript?JavaScript code is embedded in the HTML code:

<SCRIPT LANGUAGE="JavaScript"> ...JavaScript code goes here...

</SCRIPT>

Page 20: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

The most interesting feature of Javascript is event handling, whichis an asychronous program control.Normally a program executes statements sequentially, one after another, perhaps branching, butstill in a predetermined sequence.

Page 21: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

This sequence may change abruptlywhen a certain event occurs, whichneeds immediate attention. Suchsituations happen with interruptsat the hardware level, and with JAVAand C++ exceptions at the software(programming language) level.To deal with it, one needs to developan interrupt of exception handler.

Page 22: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

In JavaScript, these abrupt events aresome action requests triggered by theclient. One can program a response to suchevents using event handlers, that is, code segments that react appropriately,depending on the kind of action desiredby the client.

Page 23: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Sample events handled in JavaScript:• onClick• onMouseOver• onKeyDown• onLoad• onSelect• onAbort• and many others.

Page 24: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Handling a sample event via a form(under the assumption that the event handler has been defined separately):<FORM><INPUT TYPE = ”button” VALUE = ”Click here” onClick=”alert(You clicked on me!”</FORM>

Page 25: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

JavaScript does not have:• graphics capabilities• file I/O• networking• multithreading.

Page 26: Software Project in Computer Networks CNT 4104 Dr. Janusz Zalewski Florida Gulf Coast University.

Final Remarks• Microsoft’s response to theemergence of JavaScript wasVBScript (Visual BasicScripting Edition)• JavaScript can also run onthe server side, but is much lesspopular, because of PHP & perl