JAVASCRIPT
Overview:
JavaScript is Netscape's compact, object-based scripting language for developing client and server Internet applications. It is one of the most popular scripting language on the Net. Netscape has been working with ECMA (European Computer Manufacturers Association) to make JavaScript a standardized international programming language. ECMA is an international standards association for information and communication systems. This standardized version of JavaScript will allow companies can use the open standard language to develop their implementation of JavaScript.
Client-Side JavaScript:
JavaScript statements can be embedded directly in an HTML page. These statements can recognize and respond to user events such as mouse clicks, form input, and page navigation. For example, you can write a JavaScript function to verify that users enter valid information into a form. Without any network transmission, an HTML page with embedded JavaScript can interpret the entered text and alert the user with a message dialog if the input is invalid. Or you can use JavaScript to perform an action (such as play an audio file, execute an applet, or communicate with a plug-in) in response to the user opening or exiting a page.
JavaScript is a programmable API that allows cross-platform scripting of events, objects, and actions. It allows the page designer to access events such as startups, exits, and users' mouse clicks. JavaScript extends the programmatic capabilities of capable browsers (Netscape Navigator and MSIE 4.x) to a wide range of authors, and is easy enough for anyone who can compose HTML.
One of the most widely discussed topics of articles about JavaScript is its relationship with Java. While many of these articles point out the fact that JavaScript is not Java, it is in fact Java in some cases. This is due to the LiveConnect technology that is part of the Netscape browser (MSIE ?). LiveConnect allows you to interact between HTML, plug-ins, and Java. LiveConnect enables:
![]() |
Navigator plug-ins loaded on a page to interact with JavaScripts running on the same page. |
![]() |
Java applets loaded on a page to communicate with JavaScripts running on the same page, and vice versa. |
Client-Side Examples:
Basic Example
The following code is a simple example of JavaScript syntax.
<SCRIPT LANGUAGE="JavaScript">
The println() method prints the value of the variable foo to the Java console. You can click this button as many times as you want, and it will keep printing as did the alert() method, except you don't have to bother with closing the alert dialog every time.
LiveConnect Example 1
<SCRIPT LANGUAGE="JavaScript">
LiveConnect Example 2
The first line of code in the readPref() function calls the public static enablePrivilege() method of the Java security PrivilegeManager class, which is contained in the netscape.security package. When the enablePrivilege() method is called, the digital signature is verified and, if the signature is valid, the Java Security dialog box opens. If the signature is not valid, the script will not be executed and an alert dialog will display a warning message that an uncaught ForbiddenTargetException Java exception error occurred.
This example shows how you generally request expanded privileges from the new Java security model. In this case I passed the UniversalPreferencesRead parameter, which is the system target that's required for reading user preferences. You must grant the requested privilege for Navigator to continue executing the script.
<SCRIPT LANGUAGE="JavaScript1.2" ID="Ex2">
LiveConnect Example 3
This example uses the java.net.Inetaddress class to find the IP address of the client and prints the results on the page.
<SCRIPT LANGUAGE="JavaScript1.2" ID="Ex3">
Server-Side JavaScript:
On the server, you also embed JavaScript in HTML pages. The server-side statements can connect to relational databases from different vendors, share information across users of an application, access the file system on the server, or communicate with other applications through LiveConnect and Java. HTML pages with server-side JavaScript can also include client-side JavaScript.
In contrast to pure client-side JavaScript pages, HTML pages that use server-side JavaScript are compiled into bytecode executable files. These application executables are run by a web server that contains the JavaScript runtime engine. For this reason, creating JavaScript applications is a two-stage process.
In the first stage you create HTML pages (which can contain both client-side and server-side JavaScript statements) and JavaScript files. You then compile all of those files into a single executable.
LiveWire:
LiveWire dynamically connects databases to the Web.(see Figure 4). The user interface in HTML and application logic in JavaScript reside in the same file. LiveWires JavaScript is identical to the industry-standard client-side JavaScript developed by Netscape and Sun except that it contains database connectivity, state maintenance, and other back-end features. At runtime, the LiveWire manager interprets these files, incorporates live database data, and sends HTML back to the Web browser.
The LiveWire manager runs in the Netscape Web Server process and shares a configurable number of open database connections among all users. This requires few system resources. Also, as long as the Web server and database are running, there is no need to establish and terminate costly database connections. LiveWire very tightly integrates with the Web server and relational database.
Figure 4. LiveWire architecture
LiveConnect:
Through LiveConnect, you can access Java; through Java, you can connect to CORBA objects using Netscape Internet Service Broker for Java.
Netscape Internet Service Broker for Java (ISB for Java) is Netscape's object request broker. ISB for Java communicates with itself and with other object request brokers (ORBs) using the Internet InterORB Protocol (IIOP).
ISB for Java enables your JavaScript application to access CORBA-compliant distributed
objects deployed in an IIOP-capable ORB (including ISB for Java itself). These objects may
be part of a distributed application. To access such a distributed object, you must have a
Java stub, and that stub class must be on your CLASSPATH
. Conversely, you can
use Java and LiveConnect to expose parts of your server-side JavaScript application as
CORBA-compliant distributed objects.
For further information on how to create CORBA-compliant distributed objects using ISB for Java or how to make Java stubs for such objects see the
Netscape Internet Service Broker for Java Programmer's Guide.Server-side JavaScript applications can access a distributed object regardless of how it is deployed. The simplest alternative to consider is that the distributed object is created and run as a separate process, as illustrated in the following figure.
Figure 1 A JavaScript application as a CORBA client
Links and Acknowledgements:
Web Based Connectivity with Scrtipting Languages