<%@ page language="java" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/personalization.tld" prefix="op" %>
<html>
<head><title> Personalization Demo -  Start RE Session </title></head>
<body bgcolor="#FFFFFF">
<font size=+0>

<h2> Personalization Demo - Setup Page</h2>


<%  String REName =request.getParameter("REName");
   String target = request.getParameter("target");

   if (REName==null && target==null)  {%>
<p><b> What do you want to do ? </b></p>
<form method="get">
<INPUT TYPE="submit" NAME="target" VALUE="Start RE Session" >
<INPUT TYPE="submit" NAME="target" VALUE="End RE Session" >
</form>
<%  } else { 
  if (REName==null && target.equals("Start RE Session")) { %>
<jsp:forward page="setup2.jsp" />
<% } else { 
   if (((target==null || target.equals("Start RE Session")) && REName!=null)
        || target.equals("Return")) {
        if(target==null || (!target.equals("Return"))) { %>
<p>userID you entered is: <%= request.getParameter("userID") %> </p>
<% if(request.getParameter("userID")!=null &&
      !request.getParameter("userID").equalsIgnoreCase("null")) {
%>
<op:startRESession REName="<%= REName %>" 
	REURL="<%= request.getParameter(\"REURL\") %>" 
	RESchema="<%= request.getParameter(\"RESchema\") %>" 
	REPassword="<%= request.getParameter(\"REPassword\") %>"
	RECacheSize= "<%= request.getParameter(\"RECacheSize\") %>"
        REFlushInterval="<%= request.getParameter(\"REFlushInterval\") %>"
	session= "<%= request.getParameter(\"sess\") %>"
	userType="<%= request.getParameter(\"userType\") %>" 
	userID="<%= request.getParameter(\"userID\") %>" 
        storeUserIDIn="userIDVar"
        disableRecording = "<%= request.getParameter(\"disable\") %>" 
/>
<p> <b><i>Your RE session has been started.</p></b></i>
<p> userID returned by the tag is: <%=userIDVar%></p>
<% } else { %>
<op:startRESession REName="<%= REName %>" 
	REURL="<%= request.getParameter(\"REURL\") %>" 
	RESchema="<%= request.getParameter(\"RESchema\") %>" 
	REPassword="<%= request.getParameter(\"REPassword\") %>"
	RECacheSize= "<%= request.getParameter(\"RECacheSize\") %>"
        REFlushInterval="<%= request.getParameter(\"REFlushInterval\") %>"
	session= "<%= request.getParameter(\"sess\") %>"
	userType="<%= request.getParameter(\"userType\") %>" 
        storeUserIDIn="userIDVar"
        disableRecording = "<%= request.getParameter(\"disable\") %>" 
/>
<p> <b><i>Your RE session has been started.</p></b></i>
<p> userID returned by the tag is: <%=userIDVar%></p>

<% } 
 }%>                   
<p> <b><i>Please, choose a tag to execute: </p> </b></i>
<hr>

<form method="post">
<table>
<tr><td>&nbsp;Tag: </td><td><select name="target">
<%    String[] targets = new String[] {"Start RE Session","End RE Session",
"getcrosssellrecommendations.jsp","evaluateitem.jsp","getrecsinlist.jsp","getrecsasnext.jsp","selectfromhpinlist.jsp","selectfromhpasnext.jsp","recordnavigation.jsp","recordpurchase.jsp","recordrating.jsp","recorddemographic.jsp","removenavigationrecord.jsp","removepurchaserecord.jsp","removeratingrecord.jsp","removedemographicrecord.jsp","setvisitortocustomer.jsp"};
      String[] descs = new String[] {"startRESession","endRESession", "getCrossSellRecommendations", "evaluateItems",
"getRecommendations(results via storeResultsIn)", "getRecommendations(results via getNextItem)", "selectFromHotPicks(results via storeResultsIn)", "selectFromHotPicks(results via getNextItem)", "recordNavigation","recordPurchase","recordRating","recordDemographic","removeNavigationRecord","removePurchaseRecord","removeRatingRecord","removeDemographicRecord",
"setVisitorToCustomer" };

      for( int i=0; i<targets.length; i++) {
%>
<option value="<%=targets[i]%>"><%=descs[i]%></option>
<%
      }
%>
</select></td></tr>
</table>
<input type="submit" value="Execute Tag">
</form>
<%
   }
   else {
     if( target != null ){
        if (target.equals("End RE Session")) target="endsession.jsp";
%>
<jsp:forward page="<%=target%>" />
<%   }
   }
   } } %>
</font>
</body>
</html>
