Client-side and Server-side JavaScript (Page 1 of 6 ) This article explains the three major types of JavaScript, client-side, server-side and the core language. Server-side JavaScript is ideal for creating web applications that can be run on any platform, on any browser, and in any language. See the article for other advantages and disadvantages of each. Most people think that JavaScript is a form of Java, but that is not true. Java is a programming language developed by Sun Microsystems, while JavaScript was created by Netscape to extend the functions a browser can perform. Uses of JavaScript:
There are 3 major types of JavaScript namely:
Client-Side JavaScript (CSJS) and Server-Side JavaScript (SSJS) are dependent on the core JavaScript and cannot work without it. | ||||||||||
(Page 2 of 6 )
Core JavaScript encompasses all of the statements, operators, objects, and functions that make up the basic JavaScript language. Originally called LiveScript, JavaScript is a cross-platform, object-oriented scripting language created by Brendan Eich of Netscape. JavaScript is the world's most popular programming language, used on more platforms and in more languages than any other programming language in history. It's been licensed by more than 175 companies for inclusion in their web tools. JavaScript is even available as a standalone scripting language. You can thus take advantage of the booming popularity of JavaScript by integrating it into your own products.
There is the ECMA Script -- this is the version of JavaScript that has been standardized by ECMA (a European association for standardizing information and communications systems). The ECMA specification is based on JavaScript 1.1 and includes only the core JavaScript language. No client-specific or server-specific objects or functions were included in the ECMA standard at the time this article was written.
The following objects are part of core JavaScript:
- array
- date
- math
- number
- string
As you can see, core JavaScript contains objects that are applicable to both client and server. If you know core JavaScript, you can easily write client-side and server-side JavaScript. Again, the only distinction is that client-side and server-side JavaScript have additional objects and functions that you can use that are specific to client-side or server-side functionality. Any JavaScript libraries (.js files) you create in core JavaScript can be used on both the client and the server with no changes whatsoever.
Client-side and Server-side JavaScript - Client-Side and Server-Side JavaScript
(Page 3 of 6 )
Client-Side JavaScript
Client-Side JavaScript (CSJS) is the single most popular language on the Internet, used in major web pages which are too numerous to be counted. CSJS is composed of core JavaScript and many additional objects, such as the following:
- document
- form
- frame
- window
The objects in CSJS enable you to manipulate HTML documents (checking form fields, submitting forms, creating dynamic pages, and such) and the browser itself (directing the browser to load other HTML pages, display messages, and so on).
Server-Side JavaScript
Server-side JavaScript (SSJS) is composed of core JavaScript and additional objects and functions for accessing databases and file systems, sending e-mail, and so on. SSJS enables developers to quickly and easily create database-driven web applications by leveraging their existing knowledge of JavaScript. It's used to create and/or customize server-based applications by scripting the interaction between objects.
SSJS is included with the Netscape Enterprise Server and is ideal for creating web applications that can be run on any platform, on any browser, and in any language. Why create something in Visual Basic or PowerBuilder that can be run on only one platform, when you can create a web application with SSJS that can be run on any existing platform (such as UNIX, Mac, and Windows) and even future platforms (like BEOS)?
SSJS is also available in the Actra line of E-Commerce applications from Netscape, so that customers can customize their applications. The objects employed in the Actra implementation of SSJS are different from those used on the Enterprise Server because the data access engines are different. However, the core language is the same.
Client-side and Server-side JavaScript - CSJS vs. SSJS
(Page 4 of 6 )
The table below compares CSJS and SSJS. Note that the only syntactical difference between CSJS code and SSJS code is that for CSJS you use a <SCRIPT> tag rather than a <SERVER> tag in your HTML document. Remember, however, that SSJS provides a different set of objects from CSJS -- if you try to use CSJS objects in your server application, errors will result. Note that CSJS can be served by any server but only displayed by JavaScript-enabled browsers. SSJS must be served by a JavaScript-enabled server but can be displayed by any browser.
| CSJS | SSJS |
Tags | <SCRIPT> | <SERVER> |
Execution | Client browser (interpreted) | Server (compiled into SSJS byte code) |
Compilation | Not compiled | Application file (.web) |
Client | JavaScript-enabled | Any browser |
Server | Any server | JavaScript-enabled |
You've probably heard the terms Livewire and server-side JavaScript used interchangeably, but they're two distinctly different technologies. When Livewire was released as a product by Netscape in 1996, it contained site management utilities and provided database connectivity via SSJS on Netscape Enterprise Server 2.0. In 1997, Livewire was included with Enterprise Server 3.0, so it's no longer a separate product. Netscape began to refer to the database access engine itself as Livewire and to distinguish it from the language that the database applications are written in, SSJS.
The diagram below shows how SSJS interacts with LiveWire to connect with a variety of databases (DB2, Informix, Oracle, Sybase, and ODBC-compliant databases). SSJS provides developers with a collection of objects (such as the database, DbPool, and cursor objects) that interact with the LiveWire database access engine to communicate with a database. At the same time, some of the objects that are part of SSJS (the file, SendMail, and state management objects) do not interact with LiveWire. Remember that LiveWire involves database access only, whereas SSJS encompasses database access and additional server-side functionality.

Client-side and Server-side JavaScript - SSJS VS. CGI
(Page 5 of 6 )
So how do SSJS and the LiveWire database access engine stack up against CGI? SSJS is faster and more efficient for web applications, particularly those that access a database. In internal Netscape tests, SSJS was three times faster than Perl CGIs for database access. There are distinct advantages and disadvantages to each approach, as detailed in the following table.
SSJS | CGI |
Advantages:
| Advantages:
|
Disadvantages:
| Disadvantages:
|
Don't overlook the important advantage of using a common development language. If you're using SSJS to create your web applications, you're using JavaScript on both the client and the server. You can concentrate on a single language syntax when you create both the client and the server parts of your application. The syntax is also similar to Java, providing more synergy and code reuse in your development efforts.
Client-side and Server-side JavaScript - SSJS
(Page 6 of 6 )
In December 1997, Netscape introduced the Netscape Application Server (NAS) for use in enterprise-scale, mission-critical applications that support hundreds and thousands of concurrent users. In contrast, SSJS on the Netscape Enterprise Server is intended for use in workgroup applications that support fewer than a hundred concurrent users.
Using Live Connect, you can communicate with any Java application running on your server, including an NAS "AppLogic." You can create critical portions of your application in NAS and then communicate with them via SSJS. This way you can later migrate your entire application to NAS or reference a given service from another application without having to modify the AppLogic.
The Future of JavaScript
CSJS is supported in the Netscape Navigator web browser and has been distributed with the free source available on mozilla.org. SSJS is available in the Netscape Enterprise Server and the Netscape E-Commerce series of products (CommerceXpert, BuyerXpert, SellerXpert, and so forth). Netscape's support of SSJS has continued to increase; SSJS will be supported in future Netscape products.
The JavaScript engine is now available for licensing by third parties for inclusion in their client and server products and various tools. The engine is available in either C/C++ or Java and includes an API for developers to expose their own objects into the JavaScript programming environment. (This is how the client browser exposes objects such as window, document, and form, and how the Netscape Enterprise Server exposes the database, DbPool, and other such objects that interact with the LiveWire database service.) If your client or server application needs a scripting language, you might consider licensing JavaScript, the most popular programming language in history.
浙公网安备 33010602011771号