Internet/Software/Interactive Web sites
|HTML/XHTML, Internet and Web <|
|Table of contents|
Providing an interactive web site can be done either using client side tools or server side technologies.
Client v's Server Scripting
Web programming and scripting languages are used both server side, (i.e. at the Web server), and client side (i.e. within the users browser). Almost all interactivity at the server side uses the Common Gateway Interface, or CGI, which is part of HTTP. CGI allows someone visiting your Web site to run a program on your machine that performs a specified task. A CGI program is executed in real-time, so that it can output dynamic information - perhaps a weather reading, or the latest results from a database query. However this does make considerable use of server resources, and if many people use the web-service at once it may slow down the server.
A client-side script is a program that may accompany an HTML page or be embedded directly in it. The program executes on the client’s machine when the page loads, or at some other time such as when a link is activated. The advantage of client side scripts is that they do not use server resources, but the disadvantage is that they have to be downloaded, which may take time.
- Client Side
- Server Side
- CGI programs (Perl, Tcl, VBasic, C++, Java)
- Pre processing (ASP, Coldfusion, PHP)
A Script is embedded into the page and executed at the server before page is sent
- Active Server Pages (ASP) Microsoft
- PHP - free open source Internet standard
- Cold Fusion - Adobe (Macromedia) not a scripting language (~ tag based) proprietary, requires expensive CF server
Example :Click here to run js1_01. The diagram following shows the result in Google's chrome.
What is Java?
ASP: Active Server Pages
Active Server Page (ASP), ASPX and ASP.NET
An alternative to a CGI application is Microsoft’s Active Server Page (ASP), in which a script embedded in a Web page is executed at the server before the page is sent. ASP.NET was introduced in 2005 and VisualBasic or C# are used to code to an intermediate Common Language Runtime (CLR).
- Subservient programmer (n.d.) Retrieved August 2, 2007 from http://www.subservientprogrammer.com (No longer active :( )
- This site also gives an introduction to programming in ASPX (Click on How To Create Your Own Subservience )
PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document.
Common gateway interface (CGI)
Normally when a user requests a Web page the server sends back the requested page. However, when a user fills out a form on a Web page and sends it in, it usually needs to be processed by an application program. The Web server typically passes the form information to a small application program that processes the data, then sends back data results or a confirmation message, which the web server forwards to the user (see Figure). The common gateway interface (CGI) is the convention for passing data back and forth between a Web server and an application program, and it is part of the Web’s HTTP protocol. If you are creating a Web site and want a CGI application to get control, you specify the name of the application in a URL in an HTML file. This URL can be specified as part of the FORMS tags if you are creating a form. For example, you might code:
and the server at "mybiz.com" would pass control to the CGI application called "formprog.pl" to record the entered data and return a confirmation message. The ".pl" indicates a program written in Perl but other languages such as C, C++, Java could have been used.
Example CGI applications
- Universal Currency Converter http://www.xe.net/ucc/
- AltaVista Translations http://babelfish.altavista.com/
- Any search engine http://www.google.com/
What is CGI used for?
- guest books, web-based bulletin boards,
- auctions, classified ads, calendars,
- web based database and mailing list management, cookies, password protection,
- search engines
- rotating and randomising adverts, images, URLs or text messages,
- tracking page access statistics,
Dangers of CGI
Because CGI applications have access to the server, they can be dangerous if the Programmer is not experienced. (they provide an entry point for hackers).
Therefore ISP’s usually do not allow your own CGI scripts
But they often provide scripts for common applications like guestbooks and page counters
Perl is the most common language for writing CGI programs. This is because Perl is easier to learn and faster to code than the more structured C and C++ languages, yet quite sophisticated programs are possible.
People with experience of other programming languages will find learning Perl simple. However web designers don’t have to learn Perl, there are many CGI scripts available for download at CGI script archives. Uses of Perl/CGI include rotating and randomising adverts, images, URLs or text messages, tracking page access statistics, web-based bulletin boards, auctions, and classified adds, allowing website users to add text or URLs to websites, calendars, web based database and mailing list management, cookies, password protection, searching, and processing web forms.
Because CGI/Perl programs have access to the server, they could be dangerous if the programmer is not experienced. Thus most website hosting services do not allow people to use their own Perl scripts, although they may allow you to use them if they check the safety first - they will charge you for this service. However they often provide their own scripts to their members, checked to be safe. They usually offer common scripts such as guestbook or page counter programs and may also offer to write a custom script for you. A number of web sites also provide these common scripts for you to use on your site. In this case the script is hosted on their server (e.g. Beseen.com (http://www.beseen.com/)). .Example Perl code
Notes: \n indicates a new line, \" allows a quote(") to be added into a string.
Reference : Perl Primer, Perl/CGI Tutorial (1998). Retrieved August 18, 2003, from http://www.webdesigns1.com/perl/tutorial.html
- CGI/Perl script archives
- The CGI Resource Index ( http://www.cgi-resources.com/ )
- Open source scripts from Extropia. Retrieved from the World Wide Web: http://www.extropia.com/products.html
- Perl Script of the Week ( http://webreview.com/wr/pub/at/Script_of_the_Week/ )
- CGI/Perl resources
Since ISP’s usually don’t allow CGI scripts, you probably won’t need CGI archives like: http://www.cgi-resources.com/
A really good resource for CGI (as well as others) is http://www.thefreecountry.com Free Programmers’ Resources, Free Webmasters’ Resources,
- Free Internet Software, Free Online Documentation
Adobe (Macromedia) Flash and Director
Both Flash and Director create interactive Movies that can be run inside a web browser with a shockwave plug-in.
- An amazing interactive YouTube
Flash began as a vector based animation tool targeted at web applications, whereas Dierctor began as an authoring tool for CD-ROM/Kiosk applications. With the purchase of Macromedia in 2006 by Adobe Flash is becoming dominant and it is possible the we will see the demise of Director.
Sample of code for a Flash movie embeded in a web page
- FlashRolls (2008) Mr Snoozleberg 1 - Adventure Games - FlashRolls.com Retrieved October 12, 2008 from http://www.flashrolls.com/adventure-games/Mr-Snoozleberg-1.htm
- Goodnight Mr. Snoozleburg (Save the sleepwalking Mr. Snoozleburg!) http://www.cyberteens.com/fg/ga/ad/sn/start.html
- CanCreate(2006) WeberBrosCircus La Jester- New Show Spectacular !! Retrieved March 27, 2007 from http://www.weberbroscircus.com/