On the Map and Link the Output Parameters to the Output Fields page
of the Web interaction wizard, you can specify that the output parameter can
be saved to the session and give it a name in the session. The session is
an object that is in WebSphere® Application Server and is associated
with the current browser session. When this option is selected, the value
of the returned parameter is stored in the session with the given name.
With
the addition of some Java™ code (a Java scriptlet) in your JSP file, you can
display this value on any page. For example, assume that on your first interaction
you return an order number and you want that number to appear on each page.
Rather than have it returned on each interaction, you save it to the session
on the first interaction, then restore it from the session to display it on
those pages you want. The following Java scriptlet displays a session variable
named
ORDNO. Note that session variable names are case sensitive
and must be the same as the service program name defined in the WIT file.
You can place this code anywhere on the page on which you want to see the
order number. The comparison for not equal null, (
!=null),
verifies that the value has been set to avoid a runtime error:
Order Number:
<% String ordno = (String)session.getAttribute("ORDNO");
if(ordno !=null) { %>
<%= session.getAttribute("ORDNO") %>
<% } %>
You can also put this code in another JSP page, and
then include that JSP page in other pages where you want to see the order
number along with the other information you have on those pages. You do this
with the
<jsp:include> directive. Assume you have a JSP
page named
header.jsp in your project that has the above
code along with other header information. You can include that page in any
other page by adding the following to the other JSP page:
<jsp:include page="header.jsp"/>
Note
the trailing slash (
/) is required, or the page fails to
compile.