Pages

CGI Client-side Applets

CGI CLIENT-SIDE APPLETS



Wondered? Yes me too !! Why keep the names as CGI Client side applets instead of mere applets or Java Applets? The reason is as follows:This intends to make interaction from a client side applet which communicates with an external CGI Script.I have taken the three types of interaction in this section:
   
         (1)Making a CGI Script present on the server execute from a side CGI client side Applet.
         (2)The client side CGI Applet getting the source of a document present on the server
         (3)The client side CGI Applet invoking the method present on a remote server and getting the result

    Learning the topic of client side CGI Applets without knowing about applets is similar as building an air castle.Hence,let us take a quick glance of applets and come back to this topic sooner.


Applets-A short tour

       The objective of this section is fairly simple;Teach you something on applets and return back to the point where I have left you,that is in CGI client side Applet as soon as possible.Though the material I have presented here is of introductory sort,it does not completely deal with Applets instead it grazes just only 'grass-tips'.If you don't have any familiarity deal with Applets strongly  suggest you to try some introductory textbooks on Java Applets and come back to this point.

                 The subject matter discussed below requires Java Development kit to be installed on your computer If you don't have  JDK on your computer ,you can install it from the supplementary CD_ROM from the folder "resource/jdk1.22".

                 Java applications are standalone Java programs that can be run by using just the Java interpreter ,for example ,from command line Java applets ,however are from inside a world wide web browser,A reference to an applet is embedded in a web page using a special HTML browser downloads that applet from a web server and executes it on the local systems .The Java interpreter is built into the browser and runs the complied Java class file from there.

                  Because Java run inside a Java browser,they have access to the structure the browser provides:an existing window ,an event handling and graphics context,and the surrounding user interface.

                  A major difference between Java applets and applications is the set of restrictions placed on the how applets can operate in the name of security.Applets can't read or write to the reader's file system which means they cannot delete files or test to see what programs you have installed on the hard drive.

                  To create an applet you create a sub class of the class Applet.The Applet class,part of the Java.applet package ,provides much of the behavior your applet needs to work inside the a Java-enabled browser.Applets also take strong advantage of Java abstract windowing Tool kit (AWT),which provides behavior for creating graphical user interface(GUI)-based applets and applications drawing to the screen;creating windows,menu bars,buttons,check boxes,and other UI elements:and managing user input such as mouse clicks key-presses.The awt  classes are part of java.awt package.

                   Applets are infact different from the execution style an ordinary program.An ordinary Java program starts from the execution point where the main ()method is found .But applet falls into a different concept called as "LIFE Cycle",where applets are loaded  and finally destroyed.many such ,but here five of  the most important methods in an applet's execution :initialization,starting,stopping,destroying,and painting.

Initialization

 Initialization occurs when the applet is first loaded ,similarly to the main method applications.The initialization of an applet might include reading and parsing any parameters to the applet.creating any helper objects it needs ,setting up an initial state ,or loading images or fonts.To provide behavior the initialization of your applet ,override the init() method in your applet class.


Starting

After an applet is internalized it is started .Starting is different from initialization because it can happen many different times during an applet;s lifetime,whereas initialization happens only once .Starting can also occur if the applet was previously stopped.For example ,an applet reader return to this page .To provide start-up behavior for your applet,override the start ()  method.

       Functionality that you put in the start() method might include creating and starting up a thread to control the applet sending the appropriate messages to helper objects or in some way telling the applet to begin running.

Stopping

 Stopping and starting go hand in hand.Stopping occurs when the reader leaves the page that contains a currently running applet,or you can stop the applet yourself by calling stop.The running threads can be suspended from their execution by overriding stop()method.


Destroying

Calling the destroy() method enables the applet to clean up after itself just before it is freed or the browser exists-for example ,to stop and remove any running threads,close any open network connections or release any other objects.


Painting

painting is how an applet actually draws something on the screen be it text,a line a colored background ,or an image painting can occur many thousands of times during an applet's life cycle for example after the applet is initialized,if the browser is placed behind another window on the screen and then brought froward again,if the browser window is moved to a different position on the screen ,or perhaps repeatedly,in the case of animation.

These applets applets can actually be thought of plug ins that is they required some client side resources for them to run properly in this case ,the applets require Java virtual Machine (JVM) to be installed on the client.The web browser triggers the Java virtual machine (JVM) whenever it encounters the applet tag HTML code and makes the applet to run.More on plug-ins are discussed.

       And, Alas! There comes the end of introduction of applets and we are going to back to CGI studying this introduction alone is not enough a novice programmer to the program himself a CGI client side program.But I am for sure that is the natural way of doing things.Study more and comeback infact,I gave an interesting novel with only part of it.I promise you that learning Applet is going to be funnier than reading a novel. 

Checkpoint

You have learned applets by referring somewhere else your brains,agreed!But how to measure your effectively of learning . Just take up a calculator Applet with its complete source code from CD ROM in path code.IF you could completely interpret the code ,you can cross check point Else ,stay hack and correct yourselves to clear this checkpoint.

Charan

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.

No comments:

Post a Comment