dynamic web pages
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 PresentationTRANSCRIPT
Dynamic Web PagesBrad 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:• 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.
Server Side
• Premise
• Server Side Scripting• Active Server Pages• Hypertext Preprocessor
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
An ASP Page
• Embedded into an html page
• Tags• <% and %>
• <%@ Language= %>
• <script> and </script>
<%@ Language=VBScript %>
<html>
<body>
<% Response.Write(“Hello World!”) %>
</body>
</html>
The Browser’s Code
<html>
</body>
Hello World!
</body>
</html>
<%@ Language=VBScript %>
<html>
</body>
<% Response.Write(“Hello World!”) %>
</body>
</html>
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
ASP Objects
• Response Object
• Request Object
• Session Object
• Application Object
• Server Object
• ObjectContext Object
• ASPError Object
Response Object
• Deals with the response to the client
• Methods• Write• Redirect• Flush• End • Clear
• Handles writing cookies
Request Object
• Deals with the request to the server
• Collections• Cookies• Query String• Form
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)
Getting QueryString and Form Info
• Use html forms
• To pass via QueryString• <form method=“get”>
• To pass via Form• <form method=“post”>
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
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”
%>
Reading Cookies
• Will automatically send with request• <% var = Request.Cookies(“varName”) %>
• Will return “” if varName is not a cookie
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
Application Object
• Keeps state of the server
• Only one instance
• Used for data that is global and changed often
Reading and Writing Files
• Databases
• Text Files
ASP.Net
• Same Objects as ASP
• Uses .Net Common Runtime Languages• Visual Basic• Visual C#• Visual J#
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
A PHP Page
• Tags• <?php and ?>• <script language=“php”> and </script>• <% and %>
PHP syntax
• Instruction separation - ;
• Comments
• Variables• Start with $• Continue with name
• Must start with _ or a letter
• No type defined
PHP variables
• Eight types• Four primitive
• Integer• Floating point• String• Boolean
• Two compound• Object• Array
• Two special• Resource• NULL
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
PHP SuperGlobals
• SuperGlobal• Def: predefined variables global in every scope
• $GLOBALS• $_SERVER• $_GET• $_POST• $_COOKIES• $_FILE• $_ENV• $_REQUEST• $_SESSION
PHP Database Support
• Formats supported• Access• SQL• MySQL• Oracle
Client-Side Scripting
• Premise
• JavaScript
• VBScript
JavaScript
• Not simple Java
• Procedural Script
• Object-Orientated Script• Objects created at run-time
• Intrinsic Objects• Number• String• Boolean• Date
Client-side Scripting
• Accessing Scripts• Include in HTML document• Reference another file
• Access to client’s computer
Other Dynamic Utilities
• Flash
• Java Applets
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.