COS 381 Day 22. Agenda  Assignment #5 Corrected 2 B’s, 1 C, and 3 D’s  Next Capstone progress report due April 21  Capstone projects are DUE May 10.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
Using Perl for CGI Programming
Cos 125 Day 22. Agenda Assignment 6 Not corrected Waiting for tune-ins Assignment 7 is posted Assignment 7 Due April 2PM Left to do 1 Assignments.
Cos 125 Day 24. Agenda All students meeting 7 Pm Monday, April 19 UMS Strategic Plan Assignment #7 Posted Due April 20 Two (one?) more to go Quiz Four.
How the web works: HTTP and CGI explained
COS 381 Day 20. Agenda  Assignment #5 Due  Capstone Progress Reports Overdue Were Due April 7  Capstone projects are DUE May 10 at 1PM  Assignment.
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
COS 381 Day 23. Agenda  Questions??  Resources Source Code Available for examples in Text Book in Blackboard
Cookies & file i/o in perl. Survey (html form in notes)
COS 381 Day 23. Agenda  Questions??  Resources Source Code Available for examples in Text Book in Blackboard
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Chapter 10 Maintaining State Information Using Cookies.
Creating Web Page Forms
Chapter 10 Publishing and Maintaining Your Web Site.
HTML HTML and css 2012 Brian Davison. Assistants Dennis Doug Louise Martin Steven Stephanie.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Chapter 16 The World Wide Web Chapter Goals ( ) Compare and contrast the Internet and the World Wide Web Describe general Web processing.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
JavaScript, Fourth Edition
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
USING PERL FOR CGI PROGRAMMING
Chapter 16 The World Wide Web. 2 The Web is an infrastructure of distributed information combined with software that uses networks as a vehicle to exchange.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Website Development with PHP and MySQL Saving Data.
Chapter 9 Publishing and Maintaining Your Site. 2 Principles of Web Design Chapter 9 Objectives Understand the features of Internet Service Providers.
Cookies Web Browser and Server use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website it is required to maintain.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Chapter 10 © 2003 by Addison Wesley Longman, Inc. 1 Chapter 10 Using Perl for CGI Programming.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Web Database Programming Week 7 Session Management & Authentication.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
Chapter 5 © 2002 by Addison Wesley Longman, Inc. 1 Chapter 5 Sebesta: Programming the World Wide Web.
National College of Science & Information Technology.
Cookies Tutorial Cavisson Systems Inc..
Chapter 7 - Introduction to Common Gateway Interface (CGI)
WWW and HTTP King Fahd University of Petroleum & Minerals
Basic XHTML Tables XHTML tables—a frequently used feature that organizes data into rows and columns. Tables are defined with the table element. Table.
PHP / MySQL Introduction
10.1 The Common Gateway Interface
Presentation transcript:

COS 381 Day 22

Agenda  Assignment #5 Corrected 2 B’s, 1 C, and 3 D’s  Next Capstone progress report due April 21  Capstone projects are DUE May 10 at 1PM  Assignment #6 Posted Due Tuesday, April 18 at 3:35PM  Exam 3 which was originally scheduled for Apr 4 is going to on April 18 XML & Perl (Chap 8-10) 25 M/C WebCT  Lecture/discuss CGI using Perl  Next we will be doing Chapter 13 on ASP (with C#) and, if time allows, Chapter 14 on Database Access

FIGURE 10.5 Display of conelec.html

- We will use a form to collect survey data from users - The program needs to accumulate survey results which must be stored between form submissions - Store the current results in a file on the server - Because of concurrent use of the file, it must be protected from corruption by blocking other accesses while it is being updated - This can be done with the Perl function, flock, using the parameter value 2 to specify a lock operation and 8 to specify an unlock operation  SHOW conelec.html and its display conelec.html  (note the version in the text is different and does not work) - Two CGI programs are used for this application, one to collect survey submissions and record the new data, and one to produce the current totals - The file format is eight lines, each having seven values, the first four lines for female responses and the last four lines for male responses 10.5 A Survey Example

FIGURE 10.7 Survey results page

File Format

- The program to collect and record form data must: 1. Decode the data in the query string 2. Determine which row of the file must be modified 3. Open, lock, read, unlock, and close the survey data file 4. Split the affected data string into numbers and store them in an array 5. Modify the affected array element and join the array back into a string 6. Open, lock, write, unlock, and close the survey data file  SHOW conelec1.pl conelec1.pl.txt conelec1.plconelec1.pl.txt  (note the version in the text is different and does not work) 10.5 A Survey Example (continued)

- Tables are easier to specify with CGI.pm - The table is created with the table function - The border attribute is specified as a parameter - The table’s caption is created with a call to caption, as the second parameter to table - Each row of the table is created with a call to Tr - A heading row is created with a call to th - Data cells are created with calls to td - The calls to Tr, th, and td require references as parameters - Suppose we have three arrays of sales numbers, one for each of three salespersons; each array has one value for each day of the work week - We want to build a table of this information, using CGI.pm 10.5 A Survey Example (continued)

table({-border => "border"}, caption("Sales Figures"), Tr( [th(["Salesperson", "Mon", "Tues", "Wed", "Thu", "Fri"]), ] ) ); 10.5 A Survey Example (continued)

FIGURE 10.7 Survey results page

- The program that produces current results must: 1. Open, lock, read the lines into an array of strings, unlock, and close the data file 2. Split the first four rows (responses from females) into arrays of votes for the four age groups 3. Unshift row titles into the vote rows (making them the first elements) 4. Create the column titles row with th and put its address in an array 5. Use td on each rows of votes 6. Push the addresses of the rows of votes onto the row address array 7. Create the table using Tr on the array of row addresses 8. Repeat Steps 2-7 for the last four rows of data (responses from males)  SHOW conelec2.pl conelec2.pl.txtconelec2.plconelec2.pl.txt  (note the version in the text is different and does not work) 10.5 A Survey Example (continued)

- A session is the collection of all of the requests made by a particular browser from the time the browser is started until the user exits the browser - The HTTP protocol is stateless - But, there are several reasons why it is useful for the server to relate a request to a session - Shopping carts for many different simultaneous customers - Customer profiling for advertising - Customized interfaces for specific clients - Approaches to storing client information: - Store it on the server – too much to store! - Store it on the client machine - this works 10.6 Cookies

- A cookie is an object sent by the server to the client - Cookies are created by some software system on the server (maybe a CGI program) - Every HTTP communication between the browser and the server includes information in its header about the message - At the time a cookie is created, it is given a lifetime - Every time the browser sends a request to the server that created the cookie, while the cookie is still alive, the cookie is included - A browser can be set to reject all cookies - CGI.pm includes support for cookies cookie(-name => a_cookie_name, -value => a_value, -expires => a_time_value); - The name can be any string - The value can be any scalar value - The time is a number followed by a unit code ( d, s, m, h, M, y ) 10.6 Cookies (continued)

- Cookies must be placed in the HTTP header at the time the header is created header(-cookie => $my_cookie); - To fetch the cookies from an HTTP request, call cookie with no parameters - A hash of all current cookies is returned - To fetch the value of one particular cookie, send the cookie’s name to the cookie function $age = cookie( ′ age ′ ); - Example: A cookie that tells the client the time of his or her last visit to this site - Use the Perl function, localtime, to get the parts of time ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;  SHOW day_cookie.pl day_cookie.pl.txt day_cookie.plday_cookie.pl.txt  SHOW cookie_raider.pl cookie_raider.pl.txtcookie_raider.plcookie_raider.pl.txt 10.6 Cookies (continued)

- CGI was once a good way to create animation, but now there are several better ways - There are two ways to use CGI to create animation neither of which requires user intervention 1. Client-pull animation - The client repeatedly requests images from the server, which it displays in sequence - Problems: Internet is not fast enough, and if the approach were widely used, it would pull down the speed of the whole Internet 2. Server-push animation - The server sends the sequence of images to the client, with delays between them - Problems: Also creates a huge load on the Internet, and it is supported only by Netscape 10.7 Animation Using CGI