ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/bsfexjs.htm

71 lines
2.5 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!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> &lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello World server-side JavaScript example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;br&gt;&lt;br&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;server&gt;
function writePage()
write(&quot;&lt;center&gt;&lt;font size='6'&gt;Hello World&lt;/font&gt;&lt;/center&gt;&quot;);
&lt;/server&gt;</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> &lt;%@ page language=&quot;javascript&quot; %&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello World server-side BSF/JavaScript example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;br&gt;&lt;br&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
out.println(&quot;&lt;center&gt;&lt;font size='6'&gt;Hello World&lt;/font&gt;&lt;/center&gt;&quot;);
%&gt;</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>