JSP Directive Builder

 

In this topic ...

Quick Tip

Specifying Inputs

Related Topics ...

Overview: Creating Pages

JSP Guidelines

Use the JSP Directive builder to insert a Java Server Page directive into the top of a page. The JSP directives can be profiled enabled so that their output can appear to specified users. For example, we can use the builder to insert <%@ page import="com.bowstreet.BSConfig"%> so that code on the page can refer to the BSConfig class without having to use a fully-qualified class name.

For more information about JSP directives and their attributes, refer to a reference on Java Server Pages.

 

Quick Tip

We can view the JSP directive inserted by the JSP Directive builder by using the WebApp view in Designer.

 

Specifying Inputs

The JSP Directive builder takes the inputs described in the table below. For help on inputs common to many or all builders such as those in the Properties and HTML Attributes input groups, see "Using the Builder Call Editor."

Input name Description
Name Enter a name for this builder call. The designer tool displays this name in the builder call list.
Directive Select one of the following directives from the drop-down menu:

  • include - Select the include directive to insert a file into the servlet class at the time the JSP file is translated into a servlet.

  • page - Select the page directive to specify how you want to structure the servlet.

  • taglib - Select the taglib directive to use JSP tags defined in a library.
If you selected include from the Directive drop-down menu, enter the following: In the Name field, enter the name of the file you want to insert. The builder assumes the file is located in the <servable_content_root> directory. If the file is located in a directory under <servable_content_root>, we need to include the directory name, as shown below:

/include/filename

where

  • include is the directory containing the file you want to insert and it is a subdirectory of <servable_content_root>

  • filename is the name of the file you want to insert
If you selected page from the Directive drop-down menu, enter the following:

  • page - Select the page into which you want to insert the JSP directive.

  • autoFlush (optional) - If selected, the output buffer is flushed when it is full. If this option is not selected, an exception is triggered when the buffer is full. An example of the run-time code is the following:
    <%@ page autoflush="true" %>

  • buffer - Specify the buffer size for the out variable (type JSPWriter). When entering the buffer size, enter kb for kilobytes after the number, for example 100kb. The documents are not sent to the client until the buffer size has been reached or the page has completed loading. The buffer size must be at least 8 KB. If you turn off buffering, HTML content appears after JSP entries that define headers or status codes.
    <%@ page buffer="100kb" %>

  • errorPage (optional) - Enter the relative path of the JSP page that should process exceptions thrown, but not those caught in the current page. The builder looks in the <servable_content_root> directory for the JSP page. A typical errorPage input entry might look as follows:  /errors/pages/JSPErrorPage.jsp

  • extends (optional) - Specify the superclass of the servlet generated for the JSP page. What you enter might cause conflicts if the server is already using a custom superclass. The builder looks in the <servable_content_root> directory for the class. An example of the run-time code is the following:
    <%@ page extends="test.MyJSPBase" %>

  • import (optional) -Specify the package that you want to be imported when the JSP page is translated. The builder looks in the <servable_content_root> directory for the class. An example of the run-time code is the following:
    <%@ page import="java.util.Date" %>

  • info (optional) - Enter any additional information. This information is stored as a string, which can be retrieved by the serlvet by using the getServletInfo method. An example of the run-time code is the following:
    <%@ page info="Additional Information" %>

  • isErrorPage (optional) - Select this option if you want the current page to act as an error page for another JSP page. An example of the run-time code is the following:
    <%@ page isErrorPage="true" %>
If you selected taglib from the Directive drop-down menu, enter the following:

  • page - Select the page into which you want to insert the JSP directive.

  • prefix - Enter a prefix for the tag. The prefix is used in the taglib directive, for example:

<%@ taglib uri="Charting.tld" prefix="chart" %>

where chart is the name entered in the prefix field.

The prefix is used in front of the JSP tag. For example, assume the TLD file defines a tag named TagName and the prefix name is chart. The tag name at run-time would be the following: <chart:TagName>

  • uri - Enter the URI for the tag library descriptor (TLD) file that contains the attributes of the JSP tag you want to use. The builder looks in the <servable_content_root> directory for the TLD file. The tag library URI is put into the JSP page in the taglib directive...

<%@ taglib uri="Charting.tld" prefix="chart" %>

where Charting.tld is the name entered in the uri field.