71 lines
2.5 KiB
HTML
71 lines
2.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
|
||
|
|
||
|
<title>Example: Convert JavaScript source to the Bean Scripting Framework</title>
|
||
|
</head>
|
||
|
|
||
|
<BODY>
|
||
|
<!-- Java sync-link -->
|
||
|
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
||
|
|
||
|
<h3><a name="bsfexjs"></a>Example: Convert JavaScript source to the Bean Scripting Framework</h3>
|
||
|
|
||
|
<p>JavaScript code is one of the most popular languages of Web developers. This language supports the following base objects, plus additional objects from the Document Object Model:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>array</li>
|
||
|
<li>date</li>
|
||
|
<li>math</li>
|
||
|
<li>number</li>
|
||
|
<li>string</li>
|
||
|
</ul>
|
||
|
|
||
|
<p>Server-side JavaScript code supports the same base objects, and additional objects that support user access to databases, file systems and e-mail systems. Like client-side JavaScript code, server-side JavaScript code is also platform, browser, and language independent.</p>
|
||
|
|
||
|
<p>You can convert server-side JavaScript applications to the Bean Scripting Framework. This topic describes how to perform this conversion.</p>
|
||
|
|
||
|
<p><strong>Server-side JavaScript source code</strong></p>
|
||
|
|
||
|
<p>Suppose you have the following server-side JavaScript application:</p>
|
||
|
|
||
|
<pre> <html>
|
||
|
<head>
|
||
|
<title>Hello World server-side JavaScript example</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<br><br>
|
||
|
</body>
|
||
|
</html>
|
||
|
|
||
|
<server>
|
||
|
function writePage()
|
||
|
write("<center><font size='6'>Hello World</font></center>");
|
||
|
</server></pre>
|
||
|
|
||
|
<p><strong>Convert server-side JavaScript source code to the Bean Scripting Framework (BSF)</strong></p>
|
||
|
|
||
|
<p>Make the following changes to the JavaScript source code to enable BSF:</p>
|
||
|
|
||
|
<pre> <%@ page language="javascript" %>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Hello World server-side BSF/JavaScript example</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<br><br>
|
||
|
</body>
|
||
|
</html>
|
||
|
|
||
|
<%
|
||
|
out.println("<center><font size='6'>Hello World</font></center>");
|
||
|
%></pre>
|
||
|
|
||
|
<p>Review <a href="bsf.htm">Bean Scripting Framework</a> and <a href="bsfscene.htm">Scenario: Create a Bean Scripting Framework application</a> for deployment information and additional programming examples.</p>
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|