32
Dynamic Web Pages Brad Polzar March 8, 2007

Dynamic Web Pages

Embed Size (px)

DESCRIPTION

Dynamic Web Pages. Brad Polzar March 8, 2007. Outline. What are Dynamic Web Pages? Server Side Dynamics Active Server Pages Hypertext Preprocessor Client Side Dynamics JavaScript Java Applets Flash. What is a dynamic Web Page?. General Definition: - PowerPoint PPT Presentation

Citation preview

Page 1: Dynamic Web Pages

Dynamic Web PagesBrad Polzar March 8, 2007

Page 2: Dynamic Web Pages

Outline

• What are Dynamic Web Pages?

• Server Side Dynamics• Active Server Pages• Hypertext Preprocessor

• Client Side Dynamics• JavaScript• Java Applets• Flash

Page 3: Dynamic Web Pages

What is a dynamic Web Page?

• General Definition:• A web page that changes based on the input of the

user outside of navigating to another page.

• A more specific definition:• A web page that dynamically decides what to

display given the user’s actions and/or conditions that are currently met.

• A really picky one:• A web page that is the result of a server

dynamically deciding what html code to send based on user actions and currently met conditions.

Page 4: Dynamic Web Pages

Server Side

• Premise

• Server Side Scripting• Active Server Pages• Hypertext Preprocessor

Page 5: Dynamic Web Pages

Active Server Pages (ASP)

• Microsoft’s version of dynamic web pages

• Can use one of four scripting languages:• VBScript• JScript• PerlScript• Python

• Server Requirements• Instant ASP (iASP)• Chili!ASP• Can also run on other platforms

Page 6: Dynamic Web Pages

An ASP Page

• Embedded into an html page

• Tags• <% and %>

• <%@ Language= %>

• <script> and </script>

<%@ Language=VBScript %>

<html>

<body>

<% Response.Write(“Hello World!”) %>

</body>

</html>

Page 7: Dynamic Web Pages

The Browser’s Code

<html>

</body>

Hello World!

</body>

</html>

<%@ Language=VBScript %>

<html>

</body>

<% Response.Write(“Hello World!”) %>

</body>

</html>

Page 8: Dynamic Web Pages

ASP Collections

• Similar to a sorted array• Name / Value pairs

• Name: Brad• Class: CS4110• Date: Mar 8, 2007

Name Brad

Class CS4110

Date Mar 8, 2007

Page 9: Dynamic Web Pages

ASP Objects

• Response Object

• Request Object

• Session Object

• Application Object

• Server Object

• ObjectContext Object

• ASPError Object

Page 10: Dynamic Web Pages

Response Object

• Deals with the response to the client

• Methods• Write• Redirect• Flush• End • Clear

• Handles writing cookies

Page 11: Dynamic Web Pages

Request Object

• Deals with the request to the server

• Collections• Cookies• Query String• Form

Page 12: Dynamic Web Pages

QueryString and Form

• Both pass information from client to server

• QueryString• Passes through URL• http://www.mywebsite.com/asp?querystring• …?field1=value&field2=value2&…• Request.QueryString(field1)

• Form• Passes through request• Request.Form(field1)

Page 13: Dynamic Web Pages

Getting QueryString and Form Info

• Use html forms

• To pass via QueryString• <form method=“get”>

• To pass via Form• <form method=“post”>

Page 14: Dynamic Web Pages

Cookies

• Stored on client’s computer• Automatically sent with request• Pros:

• Keeps info off of server• Fairly small

• Cons:• Doesn’t maintain account across multiple

computers• Not all computers allow• Expiration• Only simple data types

Page 15: Dynamic Web Pages

Creating Cookies

• Simple Cookie – one value• <% Response.Cookies(“varName”) = “value” %>

• Will create if it doesn’t exist• Will overwrite if does• MUST DO THIS BEFORE THE <html> TAG!

• Complex Cookie – A Cookie with Keys• Can set a cookie to have multiple values<%

Response.Cookies(“cookieName”)(“field1”) = “value1”

Response.Cookies(“cookieName”)(“field2”) = “value2”

%>

Page 16: Dynamic Web Pages

Reading Cookies

• Will automatically send with request• <% var = Request.Cookies(“varName”) %>

• Will return “” if varName is not a cookie

Page 17: Dynamic Web Pages

Session Object

• Holds information of client’s current session

• Uses: Stores complex info• Objects• Arrays

• Negatives:• Session ending time• Space on server• Server Performance• Used through cookies

Page 18: Dynamic Web Pages

Application Object

• Keeps state of the server

• Only one instance

• Used for data that is global and changed often

Page 19: Dynamic Web Pages

Reading and Writing Files

• Databases

• Text Files

Page 20: Dynamic Web Pages

ASP.Net

• Same Objects as ASP

• Uses .Net Common Runtime Languages• Visual Basic• Visual C#• Visual J#

Page 21: Dynamic Web Pages

Hypertext Preprocessor (PHP)

• Used to stand for Personal Home Page

• Uses Apache Server

• Is a scripting language

• Is also a dynamic web technology

• Current versions are PHP4 and PHP5

Page 22: Dynamic Web Pages

A PHP Page

• Tags• <?php and ?>• <script language=“php”> and </script>• <% and %>

Page 23: Dynamic Web Pages

PHP syntax

• Instruction separation - ;

• Comments

• Variables• Start with $• Continue with name

• Must start with _ or a letter

• No type defined

Page 24: Dynamic Web Pages

PHP variables

• Eight types• Four primitive

• Integer• Floating point• String• Boolean

• Two compound• Object• Array

• Two special• Resource• NULL

Page 25: Dynamic Web Pages

PHP Variables Con’t

• PHP4 – can assign by reference

• Don’t have to initialize• Default values

• Integer and Floating Point: 0• String: empty string• Boolean: False• Array: empty array

Page 26: Dynamic Web Pages

PHP SuperGlobals

• SuperGlobal• Def: predefined variables global in every scope

• $GLOBALS• $_SERVER• $_GET• $_POST• $_COOKIES• $_FILE• $_ENV• $_REQUEST• $_SESSION

Page 27: Dynamic Web Pages

PHP Database Support

• Formats supported• Access• SQL• MySQL• Oracle

Page 28: Dynamic Web Pages

Client-Side Scripting

• Premise

• JavaScript

• VBScript

Page 29: Dynamic Web Pages

JavaScript

• Not simple Java

• Procedural Script

• Object-Orientated Script• Objects created at run-time

• Intrinsic Objects• Number• String• Boolean• Date

Page 30: Dynamic Web Pages

Client-side Scripting

• Accessing Scripts• Include in HTML document• Reference another file

• Access to client’s computer

Page 31: Dynamic Web Pages

Other Dynamic Utilities

• Flash

• Java Applets

Page 32: Dynamic Web Pages

Works Consulted• Mitchell, Scott and Atkinson, James. (2000) Sams Teach

Yourself Active Server Pages 3.0 in 21 Days. Indiapolis, IN: Sams.

• Achour, Mehdi, et al. (2007) PHP Manual. http://www.php.net/manual/en/.

• w3schools.com “ASP Tutorial.” Retrieved March 5, 2007 from http://www.w3schools.com/asp/default.asp.

• Wikipedia.org (2007) “ASP.Net.” Retrieved March 5, 2007 from http://en.wikipedia.org/wiki/ASP.NET.

• Flanagan, David. (1998) JavaScript: The Definitive Guide. Sebastopol, CA: O’Reilly.