NonStop Servlets for JavaServer Pages (5.0) System Administrator's Guide
Overview and Architecture
NonStop Servlets for JavaServer Pages (NSJSP) System Administrator’s Guide—525644-002
1-10
JSP Syntax Basics
2. Obtain a reference to the request dispatcher object for the servlet in use. Use the 
getRequestDispatcher(String name) method, which takes in the path and 
name of the servlet (URI) and returns the request dispatcher object.
3. Invoke the include or forward method of the RequestDispatcher object. Either 
method takes two arguments; the HttpServletRequest and 
HttpServletResponse objects.
Sample code for a simple JSP include directive is shown in An Example of JSP Code 
on page 1-10. 
JSP Syntax Basics
JSP syntax has two main classifications: directives and scripting elements (such as 
declarations, expressions, and scriptlets).
Directives
The Page Directive. This directive is a JSP tag used in almost every JSP source file. 
The page directive gives instructions to the JSP container that apply to the entire JSP 
source file. For example, a page directive can include comments that will become part 
of the compiled JSP file or the scripting language used in the JSP source file, 
packages the source file would import, or the error page called if an error or exception 
occurs. 
The Include Directive. This directive inserts the contents of another file in the main 
JSP file, where the directive is located. You can use the include directive for including 
copyright information, scripting language files, or anything you might want to reuse in 
other applications. The include directive allows you to separate your content into 
manageable elements such as including a common page header or footer. The page 
included can be a static HTML page or more JSP content.
Scripting Elements
Declarations. Declarations allow you to define methods or variables in a JSP page 
that will be accessible to other code within the same page.
Expressions. Expressions are simple JSP tags that convert the value of an 
expression defined between <%= %> into a string and emits that value as dynamically 
generated text. Expressions are shortcuts for generating text so that you do not have 
to call the println() method to display text.
Scriptlets. You can write Java code anywhere in a JSP page, in the form <% code 
%>. By using the import attribute of the page directive you have access to all Java 
APIs from within your scriptlet code.
An Example of JSP Code
Example 1-1 shows the use of templating, a common technique used in web-page 
development, which uses the services of more than one servlet. In this example, the 










