PHP, CGI, and JSP: A Deep Dive into Server-Side Scripting Technologies, Study notes of Computers and Information technologies

An overview of various server-side scripting technologies, including php, common gateway interface (cgi), and java server pages (jsp). Learn about their features, advantages, and disadvantages, as well as their differences from each other. Gain insights into their implementation and usage in web development.

Typology: Study notes

2010/2011

Uploaded on 09/09/2011

asdlol2
asdlol2 🇬🇧

4.4

(8)

232 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Web Based Commerce 514H3
Dr Kingsley Sage
Room 2R308, Chichester II
© University of Sussex 2009
Lecture 4
A review of web technologies
Some you may already be familiar with …
And other not
Not intending to be an exhaustive description,
rather enough to know what the technologies
are and where you might use them
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download PHP, CGI, and JSP: A Deep Dive into Server-Side Scripting Technologies and more Study notes Computers and Information technologies in PDF only on Docsity!

Web Based Commerce 514H

Dr Kingsley Sage Room 2R308, Chichester II [email protected] © University of Sussex 2009

Lecture 4

 A review of web technologies  Some you may already be familiar with …  And other not  Not intending to be an exhaustive description, rather enough to know what the technologies are and where you might use them

PHP (1)

 PHP: PHP Hypertext Proprocessor  A widely used open source general purpose scripting language that is especially suited to web development and can be embedded into HTML

PHP (2)

 A really simple example:

PHP test

Hello World

’; ?>

 Call using something like http://localhost/hello.php

PHP (5)

 A HTML form and PHP script to process it:

Your name:

Your age:

Hi . You are years old. Hi Joe. You are 22 years old.

Common Gateway Interface (CGI)

Common : Each client and server program, regardless of their OS platform, adhere to the same standard mechanism for the flow of data between client, server and gateway program  Gateway : can act as mediator between a HTTP server and any other program that can accept some form of command line input (e.g. stdin or environment variables)  Interface : A standard mechanism that provides a complete environment for developers

CGI (2)

 CGI programs go beyond the static model of a client issuing one HTML request after another  The CGI specification allows the information provider to serve up different documents depending on the client’s request  CGI specification also allows the gateway program to create new documents on the fly e.g. generating a table of contents

CGI (3)

Java Server Pages (JSP)

 JSP is a Java technology that allows developers to dynamically generate HTML, XML or other document types in response to a web client request  JSP allows Java code and other pre-defied actions to be embedded into static content  JSP syntax adds XML like tags, called JSP actions, to be used to invoke built in functionality  Allows for the creation of JSP tag libraries

JSP (2)

 JSPs are compiled into Java servlets by a Java compiler  JSP can be broken down into:

  • static data such as HTML
  • JSP directives (such as include)
  • JSP scripting elements and variables
  • JSP actions
  • custom tags

JSP (3)

 Static data is written to the HTTP response exactly as it appears in the input file  JSP directives control how the compiler generates the servlet  Scripting elements and variables: <% int serverInstanceVariable = 1; %> <% int localStackBasedVariable =1; out.println(localStackBasedVariable): %> <%= “expanded inline data “ + 1 %>

JSP (4)

 JSP actions (seen these before?):

  • jsp:forward Used to hand off the request and response to another JSP of servlet
  • jsp:fallback The content to show if the browser does not support applets
  • jsp:getProperty Gets a property from a specified JavaBean  Lots more in the course notes

J2EE

 A single standard for implementing and deploying Enterprise applications  Central to this development model is the notion of containers  Components can expect container services to be available on any J2EE platform from any vendor  Containers provide standardised access to enterprise information systems e.g. relational data through the JDBC API  Containers provide a mechanism for selecting application behaviours at assembly or deployment time through the use of XML based deployment descriptors

J2EE (2)

Active Server Pages (ASP)

 ASP is Microsoft’s server side technology for dynamically generated web pages  Programming is made easier by using built in objects. ASP 2.0 has 6 objects

  • Application
  • ASPError
  • Request
  • Response
  • Server
  • Session  Session, for example, is a cookie based session object that maintains variables from one page to another

ASP (2)

 Most ASP pages are written using VBScript  But you can use any other active scripting engine e.g. Jscript, PerlScript  An example of a very simple script using the Response object might be:

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

.NET (3)

 The Base Class Library (BCL) is a library of things available to all all languages using the .NET framework  BCL provide classes that encapsulate a number of common functions such as file reading and writing, graphic rendering, database interaction, XML document manipulation  .NET also has security mechanisms

AJAX

 Asynchronous JavaScript and XML (AJAX) is a web development technique for creating interactive web applications  The idea is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not need to be reloaded each time the user makes a change  AJAX is a technique (really a design pattern), not a specific technology

AJAX (2)

 The basic idea is to get the client doing as much of the work as possible, reducing the bandwidth requirements and thus making pages appear to load faster  For example, consider an application where you have a results set with a lot of data. The HTML can be produced locally in the browser using a JavaScript application downloaded with the original first page. The client can then ask just for the data from the server and the this is then populated into HTML in the browser  Generally only small requests need to be made to the server and relatively short responses are sent back  Data can be sorted and stored in the browser  Data format is XML

AJAX (3)

 Advantages:

  • Smart utilisation of bandwidth
  • Apparent interactivity  Disadvantages
  • Dependency on JavaScript (what do you do if it’s not available)
  • Usability (the back buttons and bookmarks – how are these implemented?)
  • Search engine optimisation: how do you index pages generated like this?
  • Compliance with standards for appearance and operation  Some AJAX code fragments shown in the course notes