INFS2052 lecture 4.1

Active Web pages - Java technology

References

Tanenbaum 3rd edition section 7.6.4: Java

Comer chapter 29 Java Technology for Active Web documents

Active Web pages

Recall Web page classification

Active pages more dynamic than "dynamic" web pages.

Internal interaction at client - not dependent on server for interaction

Interaction with server costs

  • server load
  • Web traffic - requests sent and responses received
  • latency - delay in interaction
  • Examples:

  • user can choose and explore display mode without extra requests
  • user can enter fields in forms, client can check data before submission "active forms"
  • client may do computation and updates independently of server
  • Other examples? from Web experience:........................

    Basic mechanism for active Web pages

    The browser requests a Web document in the usual way - HTTP request- URL

    The server delivers in the usual way - HTTP response - a document containing an
    executable specification of actions.

    Because of the context of the browser's request, the browser chooses to interpret that document as actions - rather than HTML for display or like other content types
    (even though it is labelled as text/plain)

    Example: in HTML an applet tag identifies an active code element.

    It can be given parameters when it executes.

    It executes in the context of the document that contains the applet invocation, within a window in the browser window.

    <h3>Question 2</h3>

    For a second chance at the money, tell us the name of the 4th layer in the OSI model.

    <applet
    codebase="http://cs.anu.edu.au/people/Chris.Johnson" code="Multichoice2" width=600 height=650>

    <param name=answer1 value="Session layer">
    <param name=answer2 value="TCP/IP">
    <param name=answer3 value="Transport layer">
    <param name=answer6 value="Datalink layer">
    <param name=answer4 value="Physical layer">

    <param name=answer5 value="Heaviside layer">

    <param name=correct value="3">

    <param name=goodprompt value="Right! the layers are 1: Physical, 2: Datalink 3: network (and as you said) 4: Transport"

    <param name=prompt value="Hint:you should have a mnemonic for the layer names">

    <param name=badprompt value="That turns out to be incorrect. Try again, please.">

    </applet>

    The function of the applet in this case was designed to display a multichoice question with a button for each answer, reacting to the selection of each with colour changes and response messages (badprompt), until the right answer or a limit on attempts is reached.

    Active Web pages - advantages

    Active Web pages - by using Java

  • Java technology
  • security in the Web context
  • other active Web technologies
  • Java Technology

    Java is a collection of strongly linked technologies from Sun Microsystems
    - proprietary system but openly usable

    The Java technologies attempt to provide active Web technology
    [and apparently the kitchen sink as well]

    Three parts to the technology:

    Java programming language

    Java runtime environment

    including security and network awareness

    Java libraries

    Java language

    The language is derived from C++ - a recent 3rd-generation language.

  • high level language
  • object oriented
  • general purpose
  • well understood roots
  • dynamic
  • strongly typed
  • static type checking
  • concurrency
  • Like many recent languages it is a core language with a set of defined libraries for many of its important functions.

    Many C++ features have been eliminated, others tidied up and strengthened.

    Not a small language.

    Unexpected complexities in definition and implementation - as with all programming languages.

    Programming language acceptors and Java

    A language acceptor is a mechanism for evaluating a program in that language.

    Classical programming language acceptors
    distinguish between compilers and interpreters.

    Compiler

    Interpreter - simple (e.g. early versions of BASIC)

    Interpreter with compiler

    Compiler - bytecode - interpreter

    The abstract machine code (bytecode)

    The Java Virtual Machine -- is the interpreter.

    In Java the modules are classes.

    The linking of the various classes in a program is lazy
    - delayed until needed at execution time

    Java Runtime Environment

    The interpreter

    The interpeter provides a PL run time system

    and implements a safety policy.

    Java technology - the Web advantages

    Performance

  • dynamic downloading of parts of code on demand
  • faster startup, no wait for classes that are not used yet/at all
  • pre-compiled bytecode is faster to execute than tokenised code
  • Size and speed of Java bytecode vs C ( a tiny program!)

    source size

    byte/object code size

    linked executable code size

    execution time

    Java

    900 bytes

    489

    -

    102 seconds

    C

    900 bytes

    1420

    5832

    15 seconds (0.3 sec optimised)

    Web safety

  • interpreter can enforce safety policies
  • Portability - platform independence

  • bytecode is machine independent
  • program creation and management is much cheaper if only one version needed
  • Java Libraries

    The Java libraries are mainly in bytecode, some are in native code.

    Provide the program interface to services of the interpreter runtime system and other added features

    Many of these are essential but not built in to the language.

  • graphics GUI
  • low level network I/O
  • web server interaction
  • file I/O
  • event capture
  • exception handling
  • The library mechanism (through collections of pre-compiled classes) provides a very powerful means of extending the language for whole areas of applications:

    has commercial possibilities (re-usable code, packages can be sold as commodity or designed for specific purposes)

    ... perhaps...

    Java safety features

    In the language:

    In the runtime environment:

    Java - and the kitchen sink

    Very popular - more for promise than present delivery

    Very appropriate for small-medium scale programs - especially applets
    - an unknown in large scale programs (and slow speed may tell)

    Not easy to program - nothing really is.

    Object code is portable.

    Provides dynamic documents economically.

    An open standard?

    A universal standard?


    Lecture Notes Index Lecture 16 Lecture 14

    Last modified: Tue Mar 30 11:30:02 EST 1999
    Queries to : infs2052@iwaki.anu.edu.au