Using stored procedures on a JSP page.

Java Primer
A JSP Architecture for Oracle Stored Procedures
by Satya Komatineni
Listing 3. Using stored procedures on a JSP page.


<%@ page import="com.storedProcedureFramework.*" %>
<%
//***************************************************
//* Initialize page data with stored procedures
//***************************************************
  PageDataProcs pageDataDef = new PageDataProcs(); <*** 2
  pageDataDef.addMainDataProc
   ("call pkg_book_info.SpGetBookPublisherDetails()");
                              <*** 1,4
  pageDataDef.addMainDataProc
   ("call pkg_book_info.SpGetBookPromoterDetails()");
                              <***6
  pageDataDef.addLoopDataProc("authors",
   "call pkg_book_info.SpGetAuthors(?)");
                              <***1,5,7
//***************************************************
//* Get IFormHandler satisfying the above data definitions
//****************************************************
  IPageData singleBookInfoPageData =
   new RelationalFormHandler(request,pageData,null);
                               <*** 8
  ILoopData authorsData =
   singleBookInfoPageData.getLoopData ("authors");
                               <*** 9
//***************************************************
//* If there is no data, Report an error
//***************************************************
  if (singleBookInfoPageData.isDataAvailable() == false)
  {
     out.println(
       "<html><body><p>No data found</p></body></html>");
     return;
   }
%>
//***************************************************
//* Paint the page
//***************************************************
<html><head></head>
<body>
Book publisher for ISBN:
  <%= singleBookInfoPageData.getValue("isbn");  %>
                               <*** 10
Book promoter for book:
  <%= singleBookInfoPageData.getValue("book_name") %>
                               <*** 10
Authors of the book are:
<hr>
<table>
   <tr><th>author name</th><th>author address</th></tr>
<%
   int turn=1;
   while(true)
         <*** loop for a table
   {
%>
      <td><%= authorsData.getValue("name",turn) %>
                               <*** 10
      <td> <%= authorsData.getValue("address",turn) %>
<%
        if (authorsData.isContinueFlag() == false)
            break;
        turn++;
   }
%>
</table></body></html>