Docsity

Java Programming: Understanding Applications, Applets, and Servlets, Study notes of Computer Science

Partial preview of the text

Download Java Programming: Understanding Applications, Applets, and Servlets and more Study notes Computer Science in PDF only on Docsity!

CS402 – Spring 2003

Introduction to Java

Handout-1b

CS402 – Spring 2003

Basic concepts

  • Objective: discuss the three types of

programs in Java:– Applications– Applets– Servlets

CS402 – Spring 2003

Applets

  • Executed on the client side (browser)
    • The browser has to be Java enabled– Applet is destroyed at the end of session
      • Applets can be used to create fancy web

pages, drop-down menus, advanced forms,custom multi-media players, etc.

CS402 – Spring 2003

Applets (II)

•^

You can use the

appletviewer

command to test

your applets– Create a file named

myapplet.html

with the following

content and save it in the same directory where youhave the

myapplet.class

file:

<APPLET

CODE=“myapplet.class”

WIDTH=

HEIGHT=50>

  • Execute:
    • C:\cs402> appletviewer myapplet.html

CS402 – Spring 2003

Servlets

  • Java programs executed on the server side• Need a web server• Servlets are substitutes to CGIs
    • CGIs usually written in C, C++, Perl, PHP– Heavy processes (start, execute, exit)– Servlets don’t exit
      • Check out http://jakarta.apache.org/

CS402 – Spring 2003

Java features

•^

Portability– Compiled code can run on any JVM– The JRE is however OS dependent

-^

Multi-threading

-^

OO programming language

-^

Automatic garbage collection

-^

Security

-^

No pointers

-^

Exception handling

-^

Rich set of libraries