Working with server scripts

For JSP targets, you write server scripts in Java. 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 an application server, 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.

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. When you create a server script for a JSP target in the integrated Script editor, you can choose from three script delimiters for your HTML tag delimiters: <% ... %>, <%! ... %>, and <%= ... %>

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>delimitertype from the pop-up menu.

    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.