Docsity

Java Applets: Executing Programs in Web Browsers, Study notes of English

Partial preview of the text

Download Java Applets: Executing Programs in Web Browsers and more Study notes English in PDF only on Docsity!

07/20/24 Distributed Computing, M. L. Liu 1

Java applets

M. L. Liu

07/20/24 Distributed Computing, M. L. Liu

Introduction

Java applets are one of three kinds of Java

programs:

An application is a standalone program that can be

invoked from the command line.

An applet is a program that runs in the context of a

browser session.

A servlet is a program that is invoked on demand on a

server program and that runs in the context of a web

server process.

07/20/24 Distributed Computing, M. L. Liu

Applet Execution - 1

An applet program is a written as a subclass of the

java.Applet class or the javax.swing.Japplet class.

There is no main method: you must override the

start method. Applet objects uses AWT for graphics.

JApplet uses SWING.

It is a Grapics object that runs in a Thread object, so

every applet can perform graphics, and runs in

parallel to the browser process.

07/20/24 Distributed Computing, M. L. Liu

Applet Execution

When the applet is loaded, these methods are automatically

invoked in order:

the init( ) method is invoked by the Java Virtual Machine.

The start( ) method

The paint( ) method.

The applet is now running and rendered on the web page.

You program the start( ) method and the paint( ) method for

your application, and invoke a repaint call to re-render the

graphics, if necessary.

At the end of the execution, the stop( ) method is invoked,

followed by the destry( ) method to deallocate the applet’s

resources.

07/20/24 Distributed Computing, M. L. Liu

HTML tags for applets - 1

** 07/20/24 Distributed Computing, M. L. Liu

HTML tags for applets - 2

end of this parameter end of this parameter specifies the end of the HTML applet code

07/20/24 Distributed Computing, M. L. Liu

Advanced Applets

 (^) You can use threads in an applet.  (^) You can make socket calls in an applet, subject to the security constraints. S e r ve r h o s t C l i e n t h o s t H TTP s e r v e r br o ws e r a pple t H o s t X a p p le t d o w n lo a d c o n n e c tio n r e q u e s t c o n n e c tio n r e q u e s t f o r b id d e n s e r v e r Y allo w e d s e r v e r Z

07/20/24 Distributed Computing, M. L. Liu

Proxy server

A proxy server can be used to circumvent the security constraints.

S e r ve r h o s t C l i e n t h o s t H TTP s e r v e r bro ws e r a pple t H o s t X a p p le t d o w n lo a d c o n n e c tio n r e q u e s t s e r v e r Y s e r v e r Z c o n n e c tio n r e q u e s t