Runtime components : Channels components : HTML Channel : Tasks : Creating a JSP
  
Creating a JSP
If you have pages that are designed using an HTML authoring tool with JSP support, you can include toolkit-provided JSP tags to help you insert the proper HTML contents. These tags are used to merge dynamic data from the runtime context with static HTML.
The requirements for such a tag are described in the com.ibm.btt.cs.html.JspContextServices interface and implemented in the com.ibm.btt.cs.html.DSEJspContextServices class. The JSPContextServices is a bean that provides the protocol for obtaining the required information from the runtime context. For example, this information includes such items as the fields that are in error due to the validation process, the formatting, and the mandatory attributes information for a specific field.
To create a JSP, you can use a regular text editor or an HTML authoring tool. Usually, if toolkit JSP tags are used, these are responsible for properly initializing the JspContextServices bean and no additional JSP code is required (see accountinquiry.jsp in the HTML Sample Application for an example). However, there may be cases where the JSP requires explicit access to the bean to get behavior that is not supported by the JSP tags. In these cases, the JSP expressions and scriplets that you should consider including in your JSPs are the following:
Instantiation and initialization of the bean as follows:
<%@ page import="com.ibm.btt.base.*" %>
<jsp:useBean id="utb" scope="page"
class="com.ibm.btt.cs.html.DSEJspContextServices">
  <% utb.initialize ( request ); %>
</jsp:useBean>
Note that the initialization of the bean may have been done by a toolkit JSP tag defined previously in the page (see transfer.jsp in the HTML Sample Application for an example). In that case, it would not be required here. In the case where access to the bean is required before any toolkit JSP tag has been defined, the initialization of the bean must be added here (see requestDataPage.jsp in the HTML Sample Application for an example).
The JspContextServices bean provides all the protocol required by the JSP. It may be used, for example, for all the rest of the tasks covered in this section.
Obtaining a value for a data element available in the operation context, as follows:
<%
  String userid = utb.getValue("userId");
%>
Obtaining the path for JSP resources, relative to the Web application server Web path (see requestDataPage.jsp in the HTML Sample Application):
<%
  String baseWebPath = utb.getBaseWebPath();
%>
If the toolkit encountered any exceptions that can be shown on the page, it saves them in the HttpServletRequest object with key dseexception or dsetypeexception. Generate appropriate error messages as the following shows:
<%= utb.getExceptionMessage ( ) %>
There are several required hidden fields that must be included in a form that posts to CSReqServlet. The toolkit provides values for dse_sessionId and dse_pageId (among other definitions) in the operation context of the operation that displayed the page to the user. You must specify the dse_operationName and optionally the dse_parentContextName for inclusion on hidden fields. These hidden fields are usually added by the toolkit JSP tags automatically. You can eventually generate all these hidden fields as follows:
<form method=post
action="/servlet/com.ibm.btt.cs.servlet.CSReqServlet">
  <!-- Write the hidden fields to the page. -->
  <!-- The operation to run is named myOperation -->
  <!-- and there is no parent context named. -->
  <%= utb.getRequiredHiddenFields() %>
  <!-- Other form fields for the user go here. -->
</form>
Go up to
Tasks