1 / 47

Part 4

Part 4. Web technologies: HTTP, CGI, PHP,Java applets). Types of Web Pages. Static Stored in file Unchanging Dynamic Formed by server Created on demand Output from a program Use Common Gateway Interface (CGI) technology. Types of Web Pages (cont). Active Executed at client

Download Presentation

Part 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Part 4 Web technologies: HTTP, CGI, PHP,Java applets) CSI 4118 – UNIVERSITY OF OTTAWA

  2. Types of Web Pages • Static • Stored in file • Unchanging • Dynamic • Formed by server • Created on demand • Output from a program • Use Common Gateway Interface (CGI) technology CSI 4118 – UNIVERSITY OF OTTAWA

  3. Types of Web Pages (cont) • Active • Executed at client • Consists of a computer program • Can interact with user • Use Java technology CSI 4118 – UNIVERSITY OF OTTAWA

  4. Summary of Web Document Types Web documents can be grouped into three categories depending on when the information in the document changes. The information in a static document remains unchanged until the author revises the document. The information in a dynamic document can change whenever a server receives a request for the document. Information displayed by an active document can change after the document has been loaded into a browser. CSI 4118 – UNIVERSITY OF OTTAWA

  5. CGI Technology • URL specifies • Location of Web server • CGI program on that server • Arguments to program • Web server • Uses TCP for communication • Accepts HTTP request from client • Runs specified CGI program • Returns output to client CSI 4118 – UNIVERSITY OF OTTAWA

  6. CGI Technology (cont) • CGI program • Performs arbitrary computation • Often written in a scripting language • Produces output file when run • Starts output with header CSI 4118 – UNIVERSITY OF OTTAWA

  7. Header in CGI Output • Stops at first blank line • Identifies • Encoding used • Type of document • Format keyword: information CSI 4118 – UNIVERSITY OF OTTAWA

  8. CGI Header Examples • HTML document header Content Type: text/html • Text document header Content Type: text/plain • Redirection header Location: /over_here/item4 CSI 4118 – UNIVERSITY OF OTTAWA

  9. Example CGI Script • Generates document • Document contains three lines of text • Header • Blank line • Document creation date CSI 4118 – UNIVERSITY OF OTTAWA

  10. Parameters • CGI programs can be parameterized • URL can contain arguments that are passed to CGI program • Question mark separates CGI path from arguments • Server places information following question mark in environment variable QUERY_STRING CSI 4118 – UNIVERSITY OF OTTAWA

  11. Example Environment Variables CSI 4118 – UNIVERSITY OF OTTAWA

  12. Encoding Information in a URL • Information that program stores between invocations: state information • Information passed to browser in form of cookie • Cookie consists of name/value pair • Long term (persistent) or short term (session) CSI 4118 – UNIVERSITY OF OTTAWA

  13. Long-Term State Information • Program lifetime • CGI program invoked by server • Program exits after generating output • To maintain persistent data • Write to file on disk • Read from file on disk CSI 4118 – UNIVERSITY OF OTTAWA

  14. Long-Term State Information • Client’s IP address in environment variable • Check if address in file • Respond to client CSI 4118 – UNIVERSITY OF OTTAWA

  15. Short-Term State Information • Each invocation of a dynamic document program can produce a document containing a new set of URLs • Use new arguments in new URLs CSI 4118 – UNIVERSITY OF OTTAWA

  16. Short-Term State Information • Argument encodes number of times executed CSI 4118 – UNIVERSITY OF OTTAWA

  17. Example of Script Execution • Initial document Content-type: text/html <HTML> This is the initial page.<BR><BR> <A HREF=“http://www.nonexist.com/cgi/ex4?1”> Click here to refresh the page.</A> </HTML> • Resulting display This is the initial page. Click here to refresh the page. CSI 4118 – UNIVERSITY OF OTTAWA

  18. Example of Script Execution • Generated output Content-type: text/html <HTML> You have displayed this page 2 times.<BR><BR> <A HREF=“http://www.nonexist.com/cgi/ex4?2”> Click here to refresh the page.</A> </HTML> • Resulting display You have displayed this page 2 times. Click here to refresh the page. CSI 4118 – UNIVERSITY OF OTTAWA

  19. Generated URL Values When it generates a document, a dynamic document program can embed state information as arguments in URLs. The argument string is passed to the program for the URL, enabling a program to pass state information from one invocation to the next. CSI 4118 – UNIVERSITY OF OTTAWA

  20. Server-Side Scripting • ASP (Active Server Pages) • JSP (Java Server Pages) • PHP (Perl Helper Pages) • ColdFusion CSI 4118 – UNIVERSITY OF OTTAWA

  21. Server-Side Scripting Server-side scripting technologies allow a dynamic page to be created from a template or skeleton that contains embedded commands or program scripts. Instead of using a computer program to generate an entire page, an interpreter copies the page and replaces only the scripting commands. CSI 4118 – UNIVERSITY OF OTTAWA

  22. Continuously Changing Information • Needed for • Animations • Rapid updates (e.g., stock prices) • Achieved with two mechanisms • Server push • Active document CSI 4118 – UNIVERSITY OF OTTAWA

  23. Server Push Technology • Client forms connection • Server sends updates repeatedly • Impractical CSI 4118 – UNIVERSITY OF OTTAWA

  24. Active Document Technology • Server • Sends computer program to client • Client • Runs program locally • Program • Controls display • Interacts with user CSI 4118 – UNIVERSITY OF OTTAWA

  25. Active Document Representation • Desire • Platform independence • Efficient execution • High-speed data transmission • Late binding • Consequence • Compact representation • Interpretive execution CSI 4118 – UNIVERSITY OF OTTAWA

  26. Active Document Translation • Compiler produces machine-independent binary • Browser interprets binary CSI 4118 – UNIVERSITY OF OTTAWA

  27. Java Technology • Developed by Sun Microsystems • Used for • Conventional applications • Active documents (applets) • Includes • Programming language • Run-time system • Class library CSI 4118 – UNIVERSITY OF OTTAWA

  28. Java Language Characteristics • High level • General purpose • Similar to C++ • Object oriented • Dynamic • Strongly typed • Statically type checked • Concurrent CSI 4118 – UNIVERSITY OF OTTAWA

  29. Java Run-Time Environment Characteristics • Interpretative execution • Automatic garbage collection • Multi-threaded execution • Internet access • Graphics support CSI 4118 – UNIVERSITY OF OTTAWA

  30. Java Library • Classes for • Graphics manipulation • Low-level network I/O • Interaction with a Web server • Run-time system access • File I/O • Conventional data structures • Event capture • Exception handling CSI 4118 – UNIVERSITY OF OTTAWA

  31. Choice of Graphics Interface Java includes an extensive graphics toolkit that consists of run-time support for graphics as well as interface software. The toolkit allows a programmer to choose a high-level interface, in which the toolkit handles details, or a low-level interface, in which the applet handles details. CSI 4118 – UNIVERSITY OF OTTAWA

  32. Example Java Applet • Window with two items • Text area • Button • Change text when button clicked CSI 4118 – UNIVERSITY OF OTTAWA

  33. Illustration of Applet Display • Initial • After user clicks button CSI 4118 – UNIVERSITY OF OTTAWA

  34. Example Applet Code CSI 4118 – UNIVERSITY OF OTTAWA

  35. Applet Invocation • Available in HTML • Uses applet tag • Specifies • Codebase (machine and path) • Code (specific class to run) • Example <applet codebase=“www.nonexist.com/pth” code=“bbb.class”> CSI 4118 – UNIVERSITY OF OTTAWA

  36. Java Functionality • HTML interface • Controls display • Interacts with user • HTTP interface • Accesses remote Web documents • Invokes other applets • Exceptions • Indicate unanticipated circumstances • Can be caught and handled CSI 4118 – UNIVERSITY OF OTTAWA

  37. Example Applet Code CSI 4118 – UNIVERSITY OF OTTAWA

  38. Example Applet Code (continued) CSI 4118 – UNIVERSITY OF OTTAWA

  39. Illustration of Applet Display CSI 4118 – UNIVERSITY OF OTTAWA

  40. JavaScript Technology • Alternative to Java technology • Provides scripting language • Browser reads and interprets script in source form • JavaScript can be integrated with HTML CSI 4118 – UNIVERSITY OF OTTAWA

  41. JavaScript Example CSI 4118 – UNIVERSITY OF OTTAWA

  42. JavaScript Example CSI 4118 – UNIVERSITY OF OTTAWA

  43. Summary • Web is major application in Internet • Client • Called browser • Fetches and displays document • Web documents • Stored on servers • Standard representation is HTML CSI 4118 – UNIVERSITY OF OTTAWA

  44. Summary (continued) • HTML • Markup language • Uses tags embedded in text • URL components • Protocol • Domain name of server • Protocol port number • Path of item • Only domain is required CSI 4118 – UNIVERSITY OF OTTAWA

  45. Summary (continued) • Static web page • Unchanging • Dynamic web page • Output from a program on the server • Active web page • Runs in browser • Consists of a computer program CSI 4118 – UNIVERSITY OF OTTAWA

  46. Summary (continued) • Dynamic web page technology • Known as CGI • CGI program usually a script • Document begins with header line • URL can contain arguments CSI 4118 – UNIVERSITY OF OTTAWA

  47. Summary (continued) • Active web page technology • Known as Java • Programming language plus runtime support • Document called applet CSI 4118 – UNIVERSITY OF OTTAWA

More Related