Working with server scripts

You can embed server scripts in your HTML pages or place them in separate script files. You can import a server script file that contains code for processing by the application server you specify, or you can include a server script file if its contents need only to be redirected, without modification, from the server to client-side browsers.

For Web site targets, if you want your server scripts to be platform-independent, you need to write in JavaScript. JavaScript is supported by ASP. For JSP targets, you typically write server scripts in Java.

Using script files

By storing code in separate script files, you can centralize common functions, thereby simplifying development and maintenance. Once you have created a script file, you can import this file into Web pages and into other script files, or you can insert the file contents into a page as embedded script. You can use the standalone Script editor to create separate script files.

For information on using the standalone Script editor, see Chapter 6, “Writing Scripts.”

Embedding server scripts

If you want server scripts to appear within an HTML page, you can write them in the integrated Script editor or insert them from a script file.

An embedded server script is delimited by HTML tags that can differ depending on the object model you are using. You can create an embedded server script for deployment to a specific application server or for platform-independent deployment.

When you create a server script in the integrated Script editor, you can make the following choices for HTML tag delimiters, with restrictions based on the target type.

Table 7-2: Server script HTML tag delimiters

Target type

Server script HTML tag delimiters

Restrictions

ASP or Basic

You can choose from four script delimiters: <% ... %>, <%! ... %>, <%= ... %>, and <SCRIPT RUNAT=SERVER> </SCRIPT>

Available to Web site targets only

JSP

You can choose from three script delimiters: <% ... %>, <%! ... %>, and <%= ... %>

Available to JSP targets only

When you add a Web target server script, the Script editor inserts <% ... %> script tag delimiters in the source for your Web page. If necessary, these tags are converted by the deployment controller to the correct syntax for the platform where you deploy your Web site.

StepsTo embed a server script on a Web page:

  1. With a Web page open in the HTML editor, right-click in the integrated Script editor.

  2. Select New Script>Server>target server type from the pop-up menu, then, if a choice is available, select the type of delimiter you want.

    The server script delimiters you select appear in the Source view for your Web page. A new server script icon appears in the Page view, which you can position on the page, and a server script item appears (as the current item) in the first drop-down list of the integrated Script editor.

Using existing ASP pages

If you have an existing ASP page that you want to use in your Web target, and that page includes server code written in VBScript, you must add the following line at the very top of the file:

 <%@ LANGUAGE=VBScript %>

Make sure you do this before opening the file in the HTML editor or importing the file into a Web target.