Advanced HTML (7)Java Applets [Archives:2003/673/Education]

archive
October 2 2003

Adnan A. Al-Harazi
Academic Head
NCC Education, Yemen Center

Java can be used to write entire applications just like a conventional programming language. All that is required to run them is a Java interpreter. Java is also very popular for writing applets (small applications). These are intended for use within a web browser and cannot be run as a stand-alone application. Typically applets extend the capabilities of the browser, or provide web site specific functionality.
Java applets are usually very small. This means that they can be downloaded from web sites very quickly. All up-to-date web browsers contain Java interpreters. This allows web sites to use applets in a very flexible fashion. Many web site designers will wish to extend the impact of their web sites by adding such applets.

Java applets are written by using Java language and the only difference between Java applets and applications is that applets don't need the main () method to run. Instead, applets need to use a separate HTML file which works as the spark to run the java applet code. This HTML file can also include the other tags needed for your web site. You will need to insert the “” tags in the place you need it to show up. In the “” tags, you will have to reference the applet code file which is type of class Java files. You have also to determine the ALIGN, WIDTH, and HEIGHT of the applet. For example if we need to insert an applet that has a file which must be written by java and saved as a class of java we add the ““tags as follows:


Notice: the applet file “Myapplet.class” must be saved in the same directory where the HTML file is saved. Many applets are available for free in the Internet. You just download the class file for the applet to the directory of your web site and then add the applet tags to the HTML code.

JavaScripts
JavaScript was developed by Netscape. It was originally known as LiveScript, which suggests its objectives clearly.
Netscape suggest that JavaScript be used as a scripting language, but the structure and design of the language makes it quite suitable for largerscale application development.
JavaScript has been standardised as ECMA-262 (ECMAScript), a European standard for scripting languages.
Despite the fact that Java and JavaScript sound similar, there is only partial relationship between the two languages. JavaScript is Netscape's crossplatform, object-based scripting language for client and server applications. JavaScript can be used to create Internet applications. These can be client side applications that run inside a browser, or server side applications hosted by the web server.
JavaScript can be used to create dynamic HTML pages that accept user input, and store data perhaps using a relational database.
JavaScript is embedded directly into HTML. This is different to Java where in client-side applications there is no need for compilation into byte-code, however, JavaScript is directly interpreted. Server-side applications can be compiled, which results in gaining some improvement in performance. An example of a JavaScript is shown in Fig 1.
Notice in the code, we add a JavaScript by handy coding it in between the

The result of this script will look like fig 2.

JavaScripts Issues
– JavaScript is not totally portable between the various browsers.
– Microsoft sometimes refers to JavaScript as Jscript.
– Microsoft also has its own native scripting language called VBScript. This is quite different to JavaScript, being based on VisualBasic.
– The compatibility problems are not quite as bad as they might appear, since plug-ins can be used to cover the differences. For example, a VBScript plugin interpreter is available for Netscape Navigator.

ActiveX
A wide variety of other tools and formats are used to create sophisticated web pages. It is not possible to provide a complete review of all of these in a lesson such as this. One of the most used toos is ActiveX.
This is currently a strategic line of development for Microsoft.There is no single product or technique which is `ActiveX'. Originally Microsoft positioned ActiveX as an alternative to Java, and this still persists in some documentation. ActiveX is perhaps better seen as an alternative to plugins.
ActiveX was based originally on Object Linking and Embedding (OLE). This was a simple technology for enabling compound documents; where part of one document can be included or embedded in another. OLE became more complex and general, introducing a standard way for one piece of software to advertise and provide services for another. This required the introduction of the Component Object Model (COM).

ActiveX Issues
– ActiveX undoubtedly provides a rich environment for the web site developer, provided that the primary target platform is Microsoft Windows.
– Microsoft will continue to support and develop ActiveX; it is clearly part of their strategic direction. There is a limitation however, Microsoft Internet Explorer has always provided support for ActiveX, but this is to be expected, since ActiveX is effectively a Microsoft developed standard. The position with other browsers has been less clear and Netscape has not fully supported ActiveX in the same way as Internet Explorer.
If you have any questions about the lessons please send me an e-mail to [email protected].
Next week: More in Advanced HTML
——
[archive-e:673-v:13-y:2003-d:2003-10-02-p:education]