What is Server-side Scripting?
Normally when a browser requests an HTML file, the server returns the file, but if the file contains a server-side script, the script inside the HTML file is executed by the server before the file is returned to the browser as plain HTML.
What is Server-side Scripting?
Normally when a browser requests an HTML file, the server returns the file, but if the file contains a server-side script, the script inside the HTML file is executed by the server before the file is returned to the browser as plain HTML.
Server-side JavaScript (SSJS) refers to JavaScript that runs on server-side and is therefore not downloaded to the browser. This term is used to differentiate it from regular JavaScript, which is predominantly used on the client-side (also referred to as client-side JavaScript or CSJS for short). The first implementation of SSJS was Netscape's LiveWire, which was included in their Enterprise Server 2.0 back in 1996. Since then, a number of other companies have followed suit in offering an alternative to the usual server-side technologies. One of the biggest players in the field was Microsoft. They supported the use of JavaScript on the server within what is now known as "classic" ASP. Along with the most common VBScript language, it also supported JavaScript and PerlScript. In reality, Microsoft utilized JScript, their own version of JavaScript.
To use JScript/JavaScript, all you had to do was set the LANGUAGE attribute in the opening script tag:
<%@LANGUAGE="JavaScript"%>
<%
Response.Write("<HTML>\r")
Response.Write("<FONT COLOR=\"red\">\"Hello World\"</FONT><BR>\r") Response.Write("</HTML>\r")
%>
Since the code runs on the server, what is sent to the client is the output of the script rather than the source code. Hence only the tags produced by the Response.Write() functions are found in the page source:
<HTML>
<FONT COLOR="red">"Hello World"</FONT><BR>
</HTML>
In addition to alleviating development complexity, server-side JavaScript offers a few other benefits that you may not have considered:
World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
Website : www.wit.net.in E-mail : [email protected]
• The same code can validate data on both the client (for immediate user feedback) and on the server (for security), so validations never get out of sync.
• The same code can prepare both the HTML DOM server side and modify it client-side, when the user changes the data or it's refreshed from the server.
• Using the same code on both the client and the server, developers have fewer technologies to learn and stay on top of, and fewer parts of the application or site to maintain.
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, shown in Figure, you create HTML pages (which can contain both client-side and server-client-side JavaScript statements) and JavaScript files. You then compile all of those files into a single executable.
Server-side JavaScript during development
World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
Website : www.wit.net.in E-mail : [email protected]
In the second stage, shown in Figure, a page in the application is requested by a client browser. The runtime engine uses the application executable to look up the source page and dynamically generate the HTML page to return. It runs any server-side JavaScript statements found on the page. The result of those statements might add new HTML or client-side JavaScript statements to the HTML page. The run-time engine then sends the resulting page over the network to the Navigator client, which runs any client-side JavaScript and displays the results.
World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
Website : www.wit.net.in E-mail : [email protected]
Server-side JavaScript during runtime
World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
Website : www.wit.net.in E-mail : [email protected]
In contrast to standard Common Gateway Interface (CGI) programs, all JavaScript source is integrated directly into HTML pages, facilitating rapid development and easy maintenance.
Server-side JavaScript's Session Management Service contains objects you can use to maintain
World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
Website : www.wit.net.in E-mail : [email protected]
data that persists across client requests, multiple clients, and multiple applications. Server-side JavaScript's LiveWire Database Service provides objects for database access that serve as an interface to Structured Query Language (SQL) database servers.