Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing.

Similar presentations


Presentation on theme: "Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing."— Presentation transcript:

1 Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing

2 Fall 2000C.Watters2 Objectives  Understand the server’s role  Understand how processing is executed on the server for dynamic web page content  CGI scripts  Active server pages  Database access  Servlets

3 Fall 2000C.Watters3 Client-Server Model

4 Fall 2000C.Watters4 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 Fall 2000C.Watters5 Server Side Processing CGI – server applications Server side scripts servlets JDBC/ODBC and databases

6 Fall 2000C.Watters6 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 Fall 2000C.Watters7 Dynamic Content Catalog for NS BlueRocks Peggys Cove Lunenburg Get province from form Query database Generate tags around the query results Send this text as body of HTTP response Province NS BrowserServer ONT Catalog for Ontario Niagara Falls Bruce Trail Goderich

8 Fall 2000C.Watters8 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 Fall 2000C.Watters9 What does an HTTP response look like? Server response = Header + object file (generally) Header object file Plain text about datadata

10 Fall 2000C.Watters10 Forms and Data Forms are part of HTML document Price: user enters data or selects options Data from form goes to server program called Submit Price:

11 Fall 2000C.Watters11 Form calling Simple CGI Example hi Do it! Where to find the program? How to get data to the server

12 Fall 2000C.Watters12 Script for hello2.cgi #!/opt/bin/perl print "Content-type: text/html\n\n"; print " \n"; print " Hello \n"; print " \n"; print " Hello, Ottawa \n"; Print “ print " \n"; try it Response doc type HTML doc

13 Fall 2000C.Watters13 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 Fall 2000C.Watters14 Perl example to ORACLE print " \n"; print " Calendar \n"; print " Course description enrol "; &SetOracle; &RunSQL("Select * from Calendar"); &StopOracle; print " \n";

15 Fall 2000C.Watters15 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 Fall 2000C.Watters16 Example Client puts tshirt in shopping cart form on web page Cart.cgi is called Makes purchase (Tshirt) Generates new page &form Add a book Cart.cgi is called Makes purchase ( book)

17 Fall 2000C.Watters17 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 Fall 2000C.Watters18 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 Fall 2000C.Watters19 Other ways to process on Server to generate dynamic data for web pages  Server side includes  Active server pages  Java server pages

20 Fall 2000C.Watters20 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 Fall 2000C.Watters21 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 Fall 2000C.Watters22 SSI example: ssitest.shtml Getting the date from the server as I need it I could do other things as well a stock quote an expected wait time a price check etc

23 Fall 2000C.Watters23 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 Fall 2000C.Watters24 Active server Page example:test1.asp Test1 = #12:00:00 AM# and Time Good Morning Ottawa Hello Everyone

25 Fall 2000C.Watters25 JSP (Java server pages)

26 Fall 2000C.Watters26 Expression. Your hostname:. Scriptlet. <% out.println("Attached GET data: " + request.getQueryString()); %> Declaration (plus expression). Accesses to page since server reboot: Directive (plus expression). Current date:

27 Fall 2000C.Watters27

28 Fall 2000C.Watters28

29 Fall 2000C.Watters29 Hello, User

30 Fall 2000C.Watters30 NOT the same as Active X Active X Components are “roughly” the same as applets

31 Fall 2000C.Watters31 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


Download ppt "Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing."

Similar presentations


Ads by Google