When you save a VGUIRecord source file, a default JSP file is created, based on the fields in the VGUIRecord part. You can edit this default JSP to change its appearance or the data displayed on it. More information on JSP technology is available atJavaServer Pages (JSP) technology
JavaServer Pages (JSP files) are ASCII files that have a .jsp suffix and contain a mixture of HTML tags and JSP syntax. A web application server transforms a JSP file into a Java™ servlet by a process known as page compilation.
Pieces of Java code called scriptlets can be inserted into JSP files. Scriptlets can be placed anywhere in the JSP source. At run time, the Java code in the scriptlet runs on the server side, but the Java code itself is not included with the HTML sent to the browser. Methods specific to UI record beans are covered in UI record bean API.
The following code shows a simple scriptlet:
<% if (x == 1) {out.println(EMPNO.getLabel())}; %>
The Java code in a scriptlet can add to the HTML by printing a string to the out PrintWriter object. This out object is created and made available to the scriptlet as part of the page compilation process of the JSP. The out object accepts only strings. If you need to print something other than a string type, you must first convert that type to a string.
There are three ways to print to the out object.
In this way, scriptlets let you access data in the VGUIRecord and use that data on the page. For specific methods for accessing a UI record bean, see UI record bean API.
The JSP file created to go along with the VGUIRecord references a UI record bean. This UI record bean gives the scriptlets in the JSP access to the data in the VGUIRecord. The JSP file references this bean with the <jsp:useBean> tag.
For example, the following code references a bean to be used in a JSP file:
<jsp:useBean id="referenceName"
class="beanClassName"
type="interfaceName"
scope="beanScope" />
The JSP file can also include JSP directives. Two of these directives are significant when working with web transactions:
The import directive lets you add Java import statements. These import statements apply to any scriptlet in the JSP. Java import statements are a shorthand to save you from having to type out the fully qualified name of the package everywhere when referring to elements inside it.
Add the following import directive to each JSP file created to work with a VGUIRecord:
<%@ page import = "com.ibm.vgj.uibean.VGDataElement" %>
The errorPage directive specifies a web page to forward the browser to in response to an uncaught exception. For example, if a UI record JSP specifies an incorrect array index in a call to the UI record bean, the JSP specified in the errorPage directive handles the error.
Do not specify CSOERRORUIR.jsp in the errorPage directive, even though CSOERRORUIR.jsp is the error page that you customize to report on TCP/IP communication problems and on problems internal to a web transaction. If you want all errors to be presented by CSOERRORUIR,jsp, specify errorPage="vagen1error.jsp".
The following example shows an errorPage directive:
<%@ page errorPage="jspName.jsp" %>