Siebel Interactive Selling Transact Server Interface Reference > The Shopping Cart >

Writing the JSP Template

The file ShoppingCart.jsp is located in the directory {WEBLOGIC_HOME}/myserver/public_html/transactserver. This file specifies the UI for the server-side shopping cart. The ShoppingCart.jsp template should first and foremost be a valid HTML document. Dynamic content and shopping cart functionality are provided using JSP tags that are embedded in the HTML.

The first JSP statement appearing in the file is:

<%@ page
info="Shopping Cart"

JSP tags always begin with "<%" and end with "%>". Once the JSP compiler has encountered the tag above, it looks for and processes all subsequent JSP tags. The info and contentType attributes should be self-explanatory. The page tag should appear somewhere before the <body> tag of the ShoppingCart.jsp page.

There are two important kinds of JSP tags used throughout the shopping cart template. These tags come in pairs and demarcate code statements or blocks.

The Code Block Pair

One is a plain-looking pair that begins with "<%" and ends with "%>". These tags demarcate a code statement or code block that needs to be executed without the result appearing on the page. You can think of these tags as almost the equivalent of "<script>" and "</script>" tags in JavaScript. Standard Java statements, like conditional "if" statements and loops, are wrapped in these tags. To insert HTML into a code block and have it appear on the page, simply end the code block with the "%>" end tag, put in the desired HTML, and then start the code again with another "<%" open tag. This makes the JSP more powerful than the JavaScript equivalent. So, you can have HTML appear as the result of a conditional statement as follows:

<p> The weather is <% if (sky.equals("blue")) { %> <b>clear!</b>
<% } else { %> <i>cloudy.</i> <% } %> <br>

If the String variable sky contains the value "blue" in the example above, the following HTML will be produced:

<p> The weather is <b>clear!</b> <br>

The Single Java Statement Pair

The other JSP tag used throughout the ShoppingCart.jsp template begins with "<%=" and ends with "%>". This tag may contain only a single Java statement, which does not need a semicolon at its close. The "<%=" tag tells the compiler to evaluate the single statement and print the result on the page, in the same location where the tag appears. A usage example of this tag is as follows:

<p><b>Welcome, <%= user_id %>!</b>

If the variable user_id contained the String value "Frank," the resulting HTML would appear as shown below:

<p><b>Welcome, Frank!</b>

This is nearly the extent of the JSP language you need to know to use and understand the ShoppingCart.jsp template. A little more JSP syntax is introduced in the next section. For further information on JSP syntax, see Sun's JavaSoft Web site, which has helpful tutorials.

 Siebel Interactive Selling Transact Server Interface Reference 
 Published: 18 April 2003