If you want to use the API within a JSP, then the API bean must be included in the code. Once this has been done, it is possible to access the API methods. This can be accomplished using the following JSP tag:
You need to properly specify the scope of the bean. In this case the scope is "session" and it is valid over multiple HTTP requests. "Request" might be used if it was desired that the bean remain valid only within the context of the current request. A more elaborate example follows.
Example of API use within a JSP
This example uses a variety of API methods to display data about the current available applications and tasks for the user.
<title> BizSite API Example JSP </title>
<p><font face="Arial, Helvetica, sans-serif">
<b> BizSite API Example JSP </b></font>
<hr>
<jsp:useBean id="bizSite" class="com.savvion.sbm.bpmportal.bizsite.api.BizSiteBean" scope="request"/>
<!-- DISPLAY THE SERVER'S TIME -->
<%= bizSite.getTime().toString() %><br><br>
<!-- LOG IN AS USER 'EBMS' -->
<b>Logging in: </b>
<%= bizSite.login( "ebms", "ebms", request ) %>
<br><br>
<% bizSite.log( "starting new BPM CustomUI API JSP test page" ); %>
<!-- GET INFORMATION ABOUT THE CURRENT USER AND SESSION -->
<b>The current user is: </b>
<%= bizSite.getCurrentUser() %><br>
<i>groups:</i> <br>
<%
String[] groups = bizSite.getGroups();
for( int i=0; i < groups.length; i++ ) {
%>
<%= groups[i] %><br>
<%
}
%>
<i>session:</i>
<%= bizSite.getSession() %><br>
<i>request:</i>
<%= request.getRequestedSessionId() %><br>
<hr>
<!-- APPLICATION INFORMATION -->
<br>
<b><u>APPLICATIONS</u></b><br>
(sorted by name)<br>
<%
com.savvion.sbm.bpmportal.bizsite.api.BizSiteApp[] p;
p = bizSite.getAppsSorted( "name" );
%>
<%
for ( int i = 0; i < p.length; i++ ) {
%>
<br>
<b>Application ( <%= i %> ) is: </b>
<%= p[i].getName() %><br>
<i>description:</i>
<%= p[i].getDescription() %><br>
<i>FYI:</i>
<%= p[i].getFYI() %><br>
<i>info:</i>
<%= p[i].getInfo() %><br>
<i>category:</i>
<%= p[i].getCategory() %><br>
<i>url:</i>
<%= p[i].getURL() %><br>
<i>full url:</i>
<%= p[i].getURL( request ) %><br>
<i>tasks:</i>
<% com.savvion.sbm.bpmportal.bizsite.api.BizSiteTask[] tasks = p[i].getTasks(); %><br>
<%
if (tasks.length ==0 )
%>
none<br>
<% else
for ( int j=0; j < tasks.length; j++ ) {
%>
<%= tasks[j].getName() %><br>
<%
}
%>
<% } %>
<!-- TASK AND DATASLOT INFORMATION -->
<hr>
<br>
<b><u>TASKS</u></b><br>
(sorted by name)<br>
<%
com.savvion.sbm.bpmportal.bizsite.api.BizSiteTask[] t;
t = bizSite.getTasks();
%>
<%
for ( int j = 0; j < t.length; j++ ) {
%>
<br>
<b>Task ( <%= j %> ) is: </b>
<%= t[j].getName() %><br>
<i>application:</i>
<%= t[j].getAppName() %><br>
<i>creator:</i>
<%= t[j].getCreator() %><br>
<i>priority:</i>
<%= t[j].getPriority() %><br>
<i>start date:</i>
<%= t[j].getStartDate() %><br>
<i>end date:</i>
<%= t[j].getEndDate() %><br>
<i>assignee:</i>
<%= t[j].getAssignee() %><br>
<i>dataslots: (sorted by name)</i><br>
<%
com.savvion.sbm.bpmportal.bizsite.api.BizSiteDataslot[] slots;
slots = t[j].getDataslotsSorted( "name" );
for( int k=0; k < slots.length; k++ ) {
%>
<%= k %>)
<%= slots[k].getName() %>
( <%= slots[k].getType() %> )
: <%= (java.lang.String) slots[k].getValue() %>
<br>
<%
}
%>
<br>
<% } %>
<hr>
<br>
<!-- LOG OUT -->
<b>Logging out: </b>
<%= bizSite.logout() %>
<br>