World Wide Web and E-Commerce - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

World Wide Web and E-Commerce

Description:

... to client as html document. may interact with ... html head title Hello, User /title /head ... Servlets (&other tricks)can be used to maintain state ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 32
Provided by: carolyn97
Category:
Tags: commerce | html | tricks | web | wide | world

less

Transcript and Presenter's Notes

Title: World Wide Web and E-Commerce


1
World Wide Web and E-Commerce
  • Servers Server Side Processing

2
Objectives
  • Understand the servers role
  • Understand how processing is executed on the
    server for dynamic web page content
  • CGI scripts
  • Active server pages
  • Database access
  • Servlets

3
Client-Server Model
4
HTTP Connection
  • 1. Client
  • makes an HTTP request for a web page
  • makes a TCP/IP connection
  • 2. Server accepts request
  • Does any processing required
  • sends page as HTTP response
  • 3. Client downloads page
  • 4. Server breaks the connection

5
Server Side Processing
  • CGI server applications
  • Server side scripts
  • servlets
  • JDBC/ODBC
  • and databases

6
Servers
  • What does a server actually do
  • 1.gets up and running in listening mode
  • creates a socket bound to its IP address waits
  • 2. Handles requests
  • detects attempt by client to connect
  • creates a new socket for communication with
    client
  • processes request
  • retrieve file
  • run cgi script
  • closes socket

socket is an abstract representation of a network
endpoint.
7
Dynamic Content
Browser
Server
Province
NS
ONT
Get province from form Query database Generate
tags around the query results Send this text as
body of HTTP response
lthtmlgt lth1gtCatalog for Ontario lth1gt ltulgt ltligtNiaga
ra Falls ltligtBruce Trail ltligtGoderich lt/ulgt lt/html
gt
  • lthtmlgt
  • lth1gtCatalog for NSlt/h1gt
  • ltulgt
  • ltligtBlueRocks
  • ltligtPeggys Cove
  • ltligtLunenburg
  • lt/ulgt
  • lt/htmlgt

8
CGI scripts
  • CGI - Common Gateway Interface
  • allows data from forms to be used by programs on
    the server
  • script is a program on the server
  • perl or C or C etc.
  • data returned to client as html document
  • may interact with a DBMS on server

9
What does an HTTP response look like?
  • Server response Header object file
    (generally)

Header object file

Plain text about data
data
10
Forms and Data
  • Forms are part of HTML document
  • ltform actionhttp//www.dal.ca/doit.cgi method
    put gt
  • Price ltinput typetext namepricegt
  • ltinput typesubmitgt
  • lt/formgt
  • user enters data or selects options
  • Data from form goes to server program called

Submit
Price
11
Form calling Simple CGI Example
Where to find the program?
  • ltHTMLgtltBODYgthi
  • ltFORM action "http//www.cs.dal.ca/watters/cgi-
    bin/hello2.cgi method postgt
  • ltInput type "submit"gt
  • lt/FORMgt
  • lt/BODYgt
  • lt/HTMLgt

How to get data to the server
Do it!
12
Script for hello2.cgi
  • !/opt/bin/perl
  • print "Content-type text/html\n\n"
  • print "ltheadgt\n"
  • print "lttitlegtHellolt/titlegt\n"
  • print "lt/headgt\n"
  • print "ltbodygt\n"
  • print "lth1gtHello, Ottawalt/h1gt\n"
  • Print ltimg srccancaphd.gifgt
  • print "lt/bodygtlt/htmlgt\n"
  • try it

Response doc type
HTML doc
13
Getting at Databases
  • ODBC - Open DataBase Connectivity
  • JDBC - java based
  • script programs can use these to make database
    queries from server databases
  • Oracle, access, etc
  • results are sent back to client as html doc

14
Perl example to ORACLE
  • print "ltheadgt\n"
  • print "lt/headgt\n"
  • print "ltbodygt\n"
  • print "lth1gtCalendarlt/h1gt\n"
  • print "ltbgtCourse description enrollt/bgtltbrgt"
  • SetOracle
  • RunSQL("Select from Calendar")
  • StopOracle
  • print "lt/bodygtlt/htmlgt\n"

15
BEING STATELESS!!
  • Each http call is a new connection
  • SO??
  • A new version of your script is run each time
  • No memory of previous events
  • pretty hard to implement a shopping cart when it
    gets emptied everytime you contact the server!

16
Example
Client puts tshirt in shopping cart form on web
page
Cart.cgi is called Makes purchase (Tshirt) Genera
tes new page form
Add a book
Cart.cgi is called Makes purchase ( book)
17
Maintaining State in a Stateless Systems
  • Use your script to write data to a temporary file
    on the server and to start each time by reading
    any data in that file
  • use javascript to process activities in a given
    session and send results to server at end only
  • Hide data in forms and send it back and forth
  • keep everything in a database
  • Use Servlets
  • gets tricky!!

18
Servlets
  • java applications that are part of the server
  • always available (faster) than cgi scripts
  • provide continuity (state) for clients
  • written in java
  • can use JDBC to access databases
  • Used for shopping, search, certificates, agents,
    portals

19
Other ways to process on Serverto generate
dynamic data for web pages
  • Server side includes
  • Active server pages
  • Java server pages

20
Server Side Include Files
  • Server Side Includes (.shtml)
  • Active Server Pages (.asp)
  • Java Server Pages (.jsp)

These functions are performed before any data
are sent to the browser
21
Server Side Includes (SSI)
  • Shtml extension
  • What happens
  • Server gets request for a page (.shtml)
  • Server checks the page for SSI commands
  • Server executes those commands and inserts new
    values into the page
  • Server sends the new page to the Browser

22
SSI example ssitest.shtml
  • lthtmlgt
  • lth1gtGetting the date from the server as I need
    itlt/h1gt
  • lt!--echo varDATE_LOCAL --gt
  • lth2gt I could do other things as welllt/h2gt
  • ltulgtltligta stock quote
  • ltligtan expected wait time
  • ltligta price check
  • ltligtetc
  • lt/ulgt
  • lt/htmlgt

23
Server Pages
  • Active Server Pages (microsoft) .asp
  • Java Server Pages (Sun) .jsp
  • Instructions for the server are included in the
    web page
  • The server notices the extension and looks for
    those instructions and executes them!

24
Active server Page exampletest1.asp
  • lt_at_ LANGUAGE"VBSCRIPT" gt
  • ltHTMLgt
  • ltBODYgt
  • Test1
  • lt If Time gt 120000 AM and Time lt120000
    PM then gt
  • lth3gtGood Morning Ottawalt/h3gt
  • lt else gt
  • ltH3gtHello Everyonelt/H3gt
  • lt end If gt
  • lt/BODYgt
  • lt/HTMLgt

25
JSP (Java server pages)
26
  • ltULgt
  • ltLIgtltBgtExpression.lt/BgtltBRgt
  • Your hostname lt request.getRemoteHost()
    gt.
  • ltLIgtltBgtScriptlet.lt/BgtltBRgt
  • lt out.println("Attached GET data "
  • request.getQueryString())
    gt
  • ltLIgtltBgtDeclaration (plus expression).lt/BgtltBRgt
  • lt! private int accessCount 0 gt
  • Accesses to page since server reboot lt
    accessCount gt
  • ltLIgtltBgtDirective (plus expression).lt/BgtltBRgt
  • lt_at_ page import "java.util." gt
  • Current date lt new Date() gt
  • lt/ULgt

27
(No Transcript)
28
(No Transcript)
29
  • lt_at_ page import"hello.NameHandler" gt
  • ltjspuseBean id"mybean" scope"page"
    class"hello.NameHandler" /gt
  • ltjspsetProperty name"mybean" property"" /gt
  • lthtmlgt
  • ltheadgtlttitlegtHello, Userlt/titlegtlt/headgt
  • ltbody bgcolor"ffffff" background"backgroun
    d.gif"gt
  • lt_at_ include file"dukebanner.html" gt
  • ltform method"get"gt
  • ltinput type"text" name"username"
    size"25"gtltbrgt
  • ltinput type"submit" value"Submit"gt
  • ltinput type"reset" value"Reset"gt
  • lt/formgt
  • lt if ( request.getParameter("username")
    ! null ) gt
  • lt_at_ include file"response.jsp" gt

30
NOT the same as Active X
  • Active X Components are roughly the same as
    applets

31
Recap
  • Servers process browser requests
  • CGI can be used to run applications on the server
    from web pages including accessing DBMS data
  • Servers are naturally stateless
  • Servlets (other tricks)can be used to maintain
    state
  • Server side includes can be used to dynamically
    create web page content before sending the page
    to the browser
  • Agents are little independent pieces of software
Write a Comment
User Comments (0)
About PowerShow.com