Applications Active Web Documents Active Web Documents
Introduction Active documents consist of code executed on computer running browser Java language allows development of active document programs Programs called applets Platform independent Secure Active Web Documents
Continuous Update: Server Push Some servers will send new versions of document: server push. Or clients may request new versions periodically: client pull. Each push or pull requires dedicated server resources. May not scale with number of clients. Also requires network bandwidth for each update. Active Web Documents
Active Documents Shifts the responsibility for updates to browser client…computation on client now. Work scales with number of active documents on client Active document can, in fact, incur less server overhead than dynamic document Active Web Documents
Active Documents Requires programming language; what should that language look like? How should the language be represented for execution? Text, binary or compressed? Multiple implementations possible; standards necessary for coordination Active Web Documents
Active Documents Active Web Documents
Java Technique for writing, compiling, downloading and executing active documents Includes: Programming language Runtime environment Class library Active Web Documents
Java: Language Resembles C++ Characteristics: Object-oriented Some C++ stuff removed or restricted Characteristics: High level, general purpose, object oriented Dynamic memory allocation Strongly typed, static type checking Concurrent Active Web Documents
Java: Runtime Environment Interpretive execution - Java language compiled into bytecodes Automatic garbage collection Multithreaded execution Internet access Graphics Active Web Documents
Java: Portability Java must be platform-independent Run-time environment clearly defined and has no implementation dependencies Bytecode representation is platform independent Java Virtual Machine. (JVM) Active Web Documents
Java: Library Library provides collection of common functions for Java programs in the form of classes. Classes for: Graphics Low-level network I/O (socket-level) Web server interaction Run-time system calls File I/O Data structures Event capture - user interaction Exception handling Active Web Documents
AWT Graphics Java graphics library called Abstract Window Toolkit (AWT) Includes high-level and low-level facilities Windows with components - scrollbars, buttons Blank rectangular area with object drawing Run-time environment implementation maps AWT functions to window system-specific functions. Active Web Documents
Java Programs Two types of Java programs: Stand alone Java programs. Java applets. What does a Java standalone program look like? How is it compiled & run? Active Web Documents
Compiling Java Programs javac translates Java source code into bytecodes Checks for correct syntax Imports classes from library Writes bytecode program to filename.class Other development environments exist May include source code management Active Web Documents
Java Applets Java applet is compiled in the usual way: javac filename results in filename.class. filename.class is put in HTML file and run. An applet is run using an appletviewer or a browser. E.g. appletviewer filename.html. An applet has a panel associated with it. Java applet has a method init() to initialize the panel associated with it. Active Web Documents
Java & Browsers Browser must include Java interpreter Java interpreter works through browser Graphics HTML Interpreter also works through native operating system File I/O Network operations Active Web Documents
A Java Applet Example Active Web Documents
Running Java Example <applet code="clickcount.class" height=150 width=400> </applet> Active Web Documents
Other Alternatives JavaScript VBScript. Interpreted scripting language Like csh for browser VBScript. Other languages compiled into Java bytecodes. Other programming technologies - Inferno Active Web Documents
Active Web Documents
Summary Active documents execute code in browser on user's computer Java is most widely used active document technology Java consists of: Programming language Run-time environment Class library Tags in browser for Java program invocation Active Web Documents