9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.

Slides:



Advertisements
Similar presentations
The Web Warrior Guide to Web Design Technologies
Advertisements

Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
1 Chapter 12 Working With Access 2000 on the Internet.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
Using Visual Basic 6.0 to Create Web-Based Database Applications
INTERNET DATABASE Chapter 9. u Basics of Internet, Web, HTTP, HTML, URLs. u Advantages and disadvantages of Web as a database platform. u Approaches for.
Introduction to Web Database Processing
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
Introduction to Web Interface Technology (CSE2030)
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Active Server Pages Chapter 1. Introduction Understand how browsers and servers interacted when the Web was young Understand what early Internet and intranet.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Introduction to Web Interface Technology (CSE2030)
Guide To UNIX Using Linux Third Edition
ASP.NET Programming with C# and SQL Server First Edition
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Creating Web Page Forms
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
A First Program Using C#
9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Using Visual Basic 6.0 to Create Web-Based Database Applications
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
Chapter 8 Cookies And Security JavaScript, Third Edition.
2-1 WEB DATABSE INTERFACING Colorado Technical University IT420.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
Producing a high-impact web experience by integrate Macromedia Flash and ASP By Katie Tuttle CS 330: Internet Architecture and Programming Project.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Database Connectivity and Server-Side Scripting Chapter 12.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
WWW and HTTP King Fahd University of Petroleum & Minerals
Chapter 27 WWW and HTTP.
Presentation transcript:

9 Chapter Nine Compiled Web Server Programs

9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic Web pages using Visual Basic, and learn the advantages and disadvantages of using CGI programs to create dynamic Web pages Pass parameter values among CGI programs

9 Chapter Objectives Learn about ActiveX dynamic-link libraries (DLLs) and their advantages and disadvantages Create an ActiveX DLL that generates a Web page Call an ActiveX DLL from an Active Server Page

9 Common Gateway Interface Common Gateway Interface (CGI) –Protocol that specifies how Web servers and compiled programs for processing user inputs that run on the Web server communicate with each other –Developed as a protocol for programs that process data entered into HTML forms and use these inputs to generate dynamic Web pages

9 Common Gateway Interface Figure 9-1: CGI processing architecture

9 Processing Inputs and Outputs in CGI Programs In the early days of mainframe computing: –Standard input (STDIN) referred to a memory location where user input from the keyboard was stored –Standard output (STDOUT) referred to a memory location where output to be displayed on the monitor was stored

9 Processing Inputs and Outputs in CGI Programs The terms STDIN and STDOUT are no longer used to reference keyboard input and monitor output STDIN and STDOUT now define a standard way of communicating the locations of inputs and outputs between different programs

9 Writing a CGI Program Using Visual Basic Visual Basic can be used to create CGI programs –VB doesn’t directly support reading from STDIN and STDOUT –To create CGI programs using VB, use a VB standard module named cgi.bas Module contains declarations of Windows API functions that enable VB to read from STDIN and write to STDOUT

9 Writing a CGI Program Using Visual Basic The cgi.bas module contains declarations of Windows API (Application Programming Interface) functions that enable Visual Basic to read from STDIN and write to STDOUT –Windows API is a set of code libraries that developers can incorporate within Windows applications written in a variety of languages, to create standard Windows program components

9

9 Debugging CGI Programs in Visual Basic The main source of errors in CGI programs developed in Visual Basic is concatenation errors, where the SQL or HTML commands are not correctly formed as text strings –Commands with incorrectly formed text strings are usually easy to spot The VB editor displays –Lines with syntax errors in red –A message box describing the error when you enter the code

9 Debugging CGI Programs in Visual Basic Figure 9-10: String concatenation error

9 Debugging CGI Programs in Visual Basic After eliminating the “red” errors, there still might be errors from text strings where the syntax is correct, but the content is not correct –This usually happens when you concatenate variable values with text strings to create SQL queries

9 Debugging CGI Programs in Visual Basic Breakpoint –A place in a program where execution is paused while the program is running, allowing the developer to examine variable values –When program execution is paused at a breakpoint, place the mouse pointer on any reference variable in the program code, and the current value of the variable will be displayed in the ToolTip window

9 Debugging CGI Programs in Visual Basic FIGURE 9-13: Code window with execution paused at breakpoint

9 Debugging CGI Programs in Visual Basic Placing the mouse pointer on variable values to determine their current values works well for variable values that are fairly short When a query string is very long, some of the text might not appear in the ToolTip window Immediate window –Testing area that is displayed when an execution is paused while a VB program is running in the VB Integrated Development Environment

9 Debugging CGI Programs in Visual Basic Figure 9-14: Query to display variable value in the Immediate window

9

9 Creating Hyperlinks to Pass Parameter Values in CGI Programs The hyperlink lists the name of the CGI program, followed by a question mark and the parameter list variable name/value pairs Each individual variable name/value pair is separated from the next by an ampersand (&)

9 Creating Hyperlinks to Pass Parameter Values in CGI Programs Figure 9-16: Code to create hyperlinks with URL parameter values

9 Creating Hyperlinks to Pass Parameter Values in CGI Programs Figure 9-17: Item ID hyperlink URL parameter value

9

9 Sharing Data Values with Other CGI Programs Form parameter –Passed to the Web server when an HTML form is submitted to the Web server by the user –Form parameters are the names and associated values of form controls are written to STDIN when a form is submitted to the Web server

9 Sharing Data Values with Other CGI Programs Cookie –Data file that is written on the user’s workstation by a program within a Web page –Available to any Web page in an application, regardless of the order in which the Web page is selected and viewed

9

9 Advantages and Disadvantages of Using CGI Programs CGI programs can be written in any programming language that allows users to write values directly to STDIN and STDOUT on a Web server A CGI program can be used with most Web servers and operating systems In contrast, Active Server Pages run only on a Microsoft Web server

9 Advantages and Disadvantages of Using CGI Programs CGI programs are compiled programs The program source code is converted into machine language when you compile the program In contrast, script commands must be converted into machine language each time the script is run –For this reason, compiled programs execute (run) much faster than scripts

9 Advantages and Disadvantages of Using CGI Programs The drawback of CGI programs is that they do not use Web server resources efficiently –On a busy Web site using CGI programs, all of the Web server’s main memory could be consumed trying to service multiple submissions of the same HTML form, and the Web server would be very slow in sending responses back to users –To solve this problem, vendors are developing products to allow a single CGI program to service multiple submissions of the same form

9

9 Using ActiveX DLLs for Server-side Web Processing A dynamic link library (DLL) is not a stand- alone program, but it contains code that can be linked to, or used by, many different programs –The code modules in a DLL are called “libraries” because their code can be “checked out “ and used by many different programs –A DLL is somewhat different from a conventional library in that the code from a specific DLL can be used simultaneously by many different programs

9 Using ActiveX DLLs for Server-side Web Processing ActiveX DLL –Code module that is stored on the Web server –Runs in the Web server’s memory space –Can be used only with Microsoft Web servers

9 Using ActiveX DLLs for Server-side Web Processing ActiveX DLLs have a significant advantage over CGI programs –A single copy of an ActiveX DLL can service an unlimited number of user requests without starting additional copies of the program

9 Differences Between ActiveX DLLs and CGI Programs Unlike a CGI program, an ActiveX DLL: –Is not a stand-alone program –Comprises one or more procedures that must be called from another program –Must be entered into the Registry of the Web server where it will be used, so that other programs will be able to call the procedures within the DLL

9 Differences Between ActiveX DLLs and CGI Programs When an ActiveX DLL is called from an ASP, you must explicitly add the code to send the form inputs as parameters from the ASP to the DLL in the ASP command that calls the ActiveX DLL procedure When an ActiveX DLL is called from an ASP, it returns outputs to the calling ASP script either as a value returned by a function, or by changing the values of variables that were passed to the ActiveX DLL as input parameters from the calling program

9 Creating an ActiveX DLL Using Visual Basic A VB ActiveX DLL consists of a class module that contains multiple functions or procedures that can be called by programs that link to the DLL Class –Template from which an object is created

9 Registry Changes Made When an ActiveX DLL is Compiled Normally, Registry entries are made by programs when they are installed or modified Registry stores information such as: –The location of program files –User preferences such as the toolbars that are displayed in a program

9 Registry Changes Made When an ActiveX DLL is Compiled To view Registry entries on a Windows95, Windows98, Windows NT, or Windows 2000 workstation, use a utility named REGEDIT REGEDIT enables users to view and change Registry entries Normally, you never need to modify the Registry manually

9 Registry Changes Made When an ActiveX DLL is Compiled Figure 9-41: Registry Editor

9 Registry Changes Made When an ActiveX DLL is Compiled Key –Parent item that can be a folder, or variable that has an associated value Value –Text string that is associated with a key variable A key folder can have a default value –Value that is associated with the key folder if a query does not specify the name of a key within the key folder

9 Retrieving Database Data in an ActiveX DLL You can an ActiveX DLL to perform operations that you cannot perform in an ASP You can also link an ActiveX DLL to an ASP to perform database operations –While database operations can be performed directly within the ASP script code, you can enhance the execution speed of the ASP if you perform some operations using a DLL, since the DLL is compiled prior to execution

9 Retrieving Database Data in an ActiveX DLL When an ActiveX DLL is called from another program, the DLL remains in the Web server’s memory until the Web server is rebooted –You cannot recompile the DLL, because the DLL is loaded into memory, and is marked as being in use by the operating system To recompile a DLL that has been called by a program, you must reboot your computer and recompile the DLL

9 Passing Form Input Parameters to an ActiveX DLL ISAPI enables you to create DLLs that can be called directly by the Web server When you call an ActiveX DLL from an ASP, the ActiveX DLL has no built-in way to directly read form inputs The alternative is to use the Request.Querystring property in the ASP to retrieve the form inputs in the ASP, and then send the parameters to the ActiveX DLL’s procedure as VB procedure parameters

9 Passing Form Input Parameters to an ActiveX DLL When creating ActiveX DLLs in VB to generate dynamic Web pages –Create functions within the ActiveX DLL that return: A text string containing all HTML commands Formatted texts Retrieved data values to be displayed by the user’s browser

9 Passing Form Input Parameters to an ActiveX DLL When creating ActiveX DLLs in VB to generate dynamic Web pages (cont.) –Create an Active Server Page to: Call functions within an ActiveX DLL Pass input parameter values to the DLL functions Display the function return value, which is a text string that represents a formatted Web page

9 Passing Form Input Parameters to an ActiveX DLL When creating ActiveX DLLs in VB to generate dynamic Web pages (cont.) –To retrieve database data in an ActiveX DLL: Create an ADODB connection object to reference a database Use the recordset Executive method to manipulate data using SQL commands

9 Chapter Summary Common Gateway Interface (CGI) is a protocol that specifies how a Web server communicates with programs running on the Web server CGI is usually used to process data that are entered into HTML forms using STDIN and STDOUT STDIN and STDOUT are memory locations on a computer that define a standard way for different programs to share the values of inputs and outputs

9 Chapter Summary A CGI program can be written in any language that can be read from STDN, write data to STDOUT, and read environment variables CGI programs can use URL parameters, form parameters, or cookies to share data values with other CGI programs CGI programs can run on most Web servers, and on a variety of operating systems

9 Chapter Summary The main drawback of CGI programs is that they do not use Web server resources efficiently Dynamic-link libraries (DLLs) are collections of compiled code modules that are called from other programs ActiveX DLLs have a significant advantage over CGI programs, since a single copy of an ActiveX DLL can service an unlimited number of user requests without starting additional copies of the program