Loading ...
Sorry, an error occurred while loading the content.
 

example of jsp syntax gone awry

Expand Messages
  • Peter Bismuti
    I ve pasted two files, the jsp file and the *.html file showing what I am seeing, hope this is helpful. ....................CUT
    Message 1 of 1 , Dec 8, 2000
      I've pasted two files, the jsp file and the *.html file showing what I am seeing, hope this
      is helpful.

      ....................CUT HERE...........................................
      <HTML>
      <HEAD>
      <TITLE>alert_type.jsp.html</TITLE>
      </HEAD>
      <BODY BGcolor=#FFFFFF TEXT=#000000>
      <PRE>
      <FONT color=#0000ff><!</FONT><FONT color=#0000ff>--</FONT>
      <FONT color=#0000ff>$Header: /disk01/cvsrepos_v3/p3platform/p3c/admininterface/jsp/alert_type.jsp,v 1.3 2000/12/08 18:11:44 pbismuti Exp $</FONT>
      <FONT color=#0000ff>$Author: pbismuti $ </FONT>
      <FONT color=#0000ff>$Date: 2000/12/08 18:11:44 $</FONT>
      <FONT color=#0000ff>$Revision: 1.3 $</FONT>
      <FONT color=#0000ff>--</FONT><FONT color=#0000ff>></FONT>
      <FONT color=#0000ff><!</FONT><FONT color=#0000ff>-- alert_type.jsp</FONT>
      <FONT color=#0000ff> </FONT>
      <FONT color=#0000ff> This page collects information necessary to create a new Alert Type. </FONT>
      <FONT color=#0000ff> It is arrived at from 'edit_alerts.jsp' by clicking on the "Add New Alert"</FONT>
      <FONT color=#0000ff> button at the bottom of the page. The user fills in the new alert "Id" and "Name"</FONT>
      <FONT color=#0000ff> and then submits the form to the servlet "InsertAlertTypeServlet".</FONT>
      <FONT color=#0000ff>--</FONT><FONT color=#0000ff>></FONT>
      <FONT color=#008b8b><%</FONT>
      <FONT color=#0000ff>/* </FONT>
      <FONT color=#0000ff> construct returnAddress - this constructs and stores as a</FONT>
      <FONT color=#0000ff> session variable the current URL by looping through the </FONT>
      <FONT color=#0000ff> parameters and building string that can be used as a request</FONT>
      <FONT color=#0000ff> using the GET method. This is used to create a </FONT><FONT color=#ff00ff>"back"</FONT><FONT color=#0000ff> link </FONT>
      <FONT color=#0000ff> in the 'admin_error.jsp' page. The string is stored in the variable </FONT><FONT color=#ff00ff>"return_address"</FONT><FONT color=#0000ff>.</FONT>
      <FONT color=#0000ff> */</FONT>
      <FONT color=#0000ff>// determine returnAddress</FONT>
      String requestURI = request.getRequestURI();
      String queryString = <FONT color=#ff00ff>""</FONT>;

      <FONT color=#0000ff>// construct query string</FONT>
      Enumeration params7 = request.getParameterNames();
      String paramName7 = <FONT color=#ff00ff>null</FONT>;
      String[] paramValues7 = <FONT color=#ff00ff>null</FONT>;

      <B><FONT color=#a52a2a>while</FONT></B> (params7.hasMoreElements()) {
      paramName7 = (String) params7.nextElement();
      paramValues7 = request.getParameterValues(paramName7);
      <B><FONT color=#a52a2a>for</FONT></B> (<B><FONT color=#2e8b57>int</FONT></B> i=<FONT color=#ff00ff>0</FONT>; i<paramValues7.length; i++){
      queryString += paramName7+<FONT color=#ff00ff>"="</FONT>+paramValues7[i].toString()+<FONT color=#ff00ff>"&"</FONT>;
      }
      }
      <B><FONT color=#a52a2a>if</FONT></B> (queryString.length() > <FONT color=#ff00ff>0</FONT>){
      queryString = queryString.substring(<FONT color=#ff00ff>0</FONT>,queryString.length()-<FONT color=#ff00ff>1</FONT>);
      }

      <FONT color=#0000ff>// now construct return address</FONT>
      String returnAddress = <FONT color=#ff00ff>null</FONT>;
      returnAddress = requestURI + <FONT color=#ff00ff>"?"</FONT> + queryString;

      <FONT color=#0000ff>// now set a session attribute</FONT>
      session.removeAttribute(<FONT color=#ff00ff>"returnAddress"</FONT>);
      session.setAttribute(<FONT color=#ff00ff>"returnAddress"</FONT>,returnAddress);
      <FONT color=#008b8b>%></FONT>

      <FONT color=#008b8b><</FONT><B><FONT color=#a52a2a>HTML</FONT></B><FONT color=#008b8b>></FONT>
      <FONT color=#008b8b><</FONT><B><FONT color=#a52a2a>HEAD</FONT></B><FONT color=#008b8b>></FONT>
      <FONT color=#008b8b><</FONT><B><FONT color=#a52a2a>TITLE</FONT></B><FONT color=#008b8b>></FONT><B><FONT color=#ff00ff>Alert Type</FONT></B><FONT color=#008b8b></</FONT><B><FONT color=#a52a2a>TITLE</FONT></B><FONT color=#008b8b>></FONT>
      <FONT color=#008b8b><</FONT><B><FONT color=#a52a2a>SCRIPT</FONT></B><FONT color=#008b8b>></FONT>
      <FONT color=#a020f0>//........................................................................</FONT>
      <FONT color=#a020f0>function Cancel(){</FONT>
      <FONT color=#a020f0> location = "/edit_alerts.jsp";</FONT>
      <FONT color=#a020f0>}</FONT>
      <FONT color=#a020f0>//........................................................................</FONT>
      <FONT color=#a020f0>// onSubmit() - do some error checking before the form is submitted. </FONT>
      <FONT color=#a020f0>//........................................................................</FONT>
      <FONT color=#a020f0> function onSubmit(form){</FONT>
      <FONT color=#a020f0> var fc = isNotEmpty("Alert ID",form.alertId.value);</FONT>
      <FONT color=#a020f0> var lc = isNotEmpty("Name",form.name.value);</FONT>
      <FONT color=#a020f0> var ai = isNotInside(form.alertId.value,alertIdArray,"alertId");</FONT>
      <FONT color=#a020f0> var av = isSafeString(form.alertId.value,"ID");</FONT>
      <FONT color=#a020f0> var ann = isSafeString(form.name.value,"Name");</FONT>
      <FONT color=#a020f0> var an = isNotInside(form.name.value,alertNameArray,"alertName");</FONT>
      <FONT color=#a020f0> return (fc&&lc&&ai&&av&&ann</FONT><FONT color=#6a5acd>&&an);</FONT>
      <FONT color=#a020f0> }</FONT>
      <FONT color=#a020f0>//........................................................................</FONT>
      <FONT color=#a020f0> function isNotEmpty(name,value){</FONT>
      <FONT color=#a020f0> if (value.length ==0){</FONT>
      <FONT color=#a020f0> alert("ERROR: "+name+" must be entered.");</FONT>
      <FONT color=#a020f0> return false;</FONT>
      <FONT color=#a020f0> }else{</FONT>
      <FONT color=#a020f0> return true;</FONT>
      <FONT color=#a020f0> }</FONT>
      <FONT color=#a020f0> }</FONT>
      <FONT color=#a020f0>//........................................................................</FONT>
      <FONT color=#a020f0> function isNotInside(alertData,alertDataArray,type){</FONT>
      <FONT color=#a020f0> for (var i=0; i</FONT><FONT color=#008b8b><</FONT>alertDataArray<FONT color=#008b8b>.length; i++){</FONT>
      <FONT color=#008b8b> if (strip(alertData) =</FONT>=<FONT color=#008b8b> strip(alertDataArray[i])){</FONT>
      <FONT color=#008b8b> alert(</FONT><FONT color=#ff00ff>"ERROR: the "</FONT><FONT color=#008b8b> +</FONT><B><FONT color=#2e8b57>type</FONT></B><FONT color=#008b8b>+ </FONT><FONT color=#ff00ff>" '"</FONT><FONT color=#008b8b>+alertData+</FONT><FONT color=#ff00ff>"' already exists, please choose another."</FONT><FONT color=#008b8b>);</FONT>
      <FONT color=#008b8b> return false;</FONT>
      <FONT color=#008b8b> }</FONT>
      <FONT color=#008b8b> }</FONT>
      <FONT color=#008b8b> return true;</FONT>
      <FONT color=#008b8b> }</FONT>
      <FONT color=#008b8b>//........................................................................</FONT>
      <FONT color=#008b8b>function strip(string){</FONT>
      <FONT color=#008b8b> string =</FONT> string.replace(/\s+$/,"");<FONT color=#008b8b> // strip off leading and trailing</FONT>
      <FONT color=#008b8b> string =</FONT> string.replace(/^\s+/,"");
      <FONT color=#008b8b> return string;</FONT>
      <FONT color=#008b8b>}</FONT>
      <FONT color=#008b8b>//........................................................................</FONT>
      <FONT color=#008b8b>function isSafeString(s,</FONT><B><FONT color=#2e8b57>name</FONT></B><FONT color=#008b8b>) {</FONT>
      <FONT color=#008b8b> illegalChar=</FONT><FONT color=#ff00ff>"\"'\\</FONT><FONT color=#6a5acd>&#+";</FONT>
      <FONT color=#ff00ff> goodString = true;</FONT>
      <FONT color=#ff00ff> for (var i=0;i<6;i++) {</FONT>
      <FONT color=#ff00ff> if (s.indexOf(illegalChar.substring(i,i+1))!=-1){</FONT>
      <FONT color=#ff00ff> alert("ERROR: invalid value for " + name+".\nIllegal character detected: '"+illegalChar.substring(i,i+1)+"'.");</FONT>
      <FONT color=#ff00ff> goodString = false;</FONT>
      <FONT color=#ff00ff> }</FONT>
      <FONT color=#ff00ff> }</FONT>
      <FONT color=#ff00ff> return goodString;</FONT>
      <FONT color=#ff00ff>}</FONT>

      <FONT color=#ff00ff>function cleanApostrophe(s){</FONT>
      <FONT color=#ff00ff> var s2 = "";</FONT>
      <FONT color=#ff00ff> for(var i=0;i<s.length;i++){</FONT>
      <FONT color=#ff00ff> var c = s.charAt(i);</FONT>
      <FONT color=#ff00ff> if(c=="'")</FONT>
      <FONT color=#ff00ff> s2 += "</FONT><FONT color=#008b8b>\</FONT><FONT color=#ff00ff>'";</FONT>
      <FONT color=#ff00ff> else</FONT>
      <FONT color=#ff00ff> s2 += c;</FONT>
      <FONT color=#ff00ff> }</FONT>
      <FONT color=#ff00ff> return s2;</FONT>
      <FONT color=#ff00ff>}</FONT>

      <FONT color=#ff00ff></SCRIPT></FONT>
      <FONT color=#ff00ff><BODY BGCOLOR=#FFFFFF ALINK=#0000FF VLINK=#0000FF></FONT>
      <FONT color=#ff00ff><%@</FONT>
      <FONT color=#ff00ff> page import="</FONT>
      <FONT color=#ff00ff> p3c.admininterface.ejb.TemplateManager.*,</FONT>
      <FONT color=#ff00ff> p3c.admininterface.ejb.Help.*,</FONT>
      <FONT color=#ff00ff> p3c.admininterface.ejb.*,</FONT>
      <FONT color=#ff00ff> p3c.admininterface.*,</FONT>
      <FONT color=#ff00ff> java.text.*,</FONT>
      <FONT color=#ff00ff> "</FONT>
      <FONT color=#ff00ff>%></FONT>
      <FONT color=#ff00ff><%@ include file="/includes/validate_user.jsp" %></FONT>
      <FONT color=#ff00ff><%@ include file="/includes/admin_header.jsp" %></FONT>

      <FONT color=#ff00ff><%</FONT>
      <FONT color=#ff00ff> // retrieve the request input parameters</FONT>
      <FONT color=#ff00ff> // then define an array in javascript that can be used</FONT>
      <FONT color=#ff00ff> // to check against adding a new alert with an already</FONT>
      <FONT color=#ff00ff> // existing alertId</FONT>

      <FONT color=#ff00ff> out.println("<SCRIPT>");</FONT>

      <FONT color=#ff00ff> java.util.Enumeration params = request.getParameterNames();</FONT>
      <FONT color=#ff00ff> String paramName = null;</FONT>
      <FONT color=#ff00ff> String[] paramValues = null;</FONT>

      <FONT color=#ff00ff> // alertIdArray</FONT>
      <FONT color=#ff00ff> paramName = "alertIdArray";</FONT>
      <FONT color=#ff00ff> paramValues = null;</FONT>
      <FONT color=#ff00ff> out.println(" alertIdArray = [");</FONT>
      <FONT color=#ff00ff> paramValues = request.getParameterValues(paramName);</FONT>
      <FONT color=#ff00ff> for (int i = 0; paramValues != null && i < paramValues.length -1; i++) {</FONT>
      <FONT color=#ff00ff> out.println("\""+paramValues[i].toString() + "\",");</FONT>
      <FONT color=#ff00ff> }</FONT>
      <FONT color=#ff00ff> if(paramValues != null)</FONT>
      <FONT color=#ff00ff> out.println("\""+paramValues[paramValues.length-1].toString() + "\"");</FONT>
      <FONT color=#ff00ff> out.println("];\n");</FONT>

      <FONT color=#ff00ff> // alertNameArray</FONT>
      <FONT color=#ff00ff> paramName = "alertNameArray";</FONT>
      <FONT color=#ff00ff> paramValues = null;</FONT>
      <FONT color=#ff00ff> out.println(" alertNameArray = [");</FONT>
      <FONT color=#ff00ff> paramValues = request.getParameterValues(paramName);</FONT>
      <FONT color=#ff00ff> for (int i = 0; paramValues != null && i < paramValues.length -1; i++) {</FONT>
      <FONT color=#ff00ff> out.println("\""+paramValues[i].toString() + "\",");</FONT>
      <FONT color=#ff00ff> }</FONT>
      <FONT color=#ff00ff> if(paramValues != null)</FONT>
      <FONT color=#ff00ff> out.println("\""+paramValues[paramValues.length-1].toString() + "\"");</FONT>
      <FONT color=#ff00ff> out.println("];\n");</FONT>

      <FONT color=#ff00ff> out.println("</SCRIPT>");</FONT>

      <FONT color=#ff00ff> // just in case</FONT>
      <FONT color=#ff00ff> int clientId;</FONT>
      <FONT color=#ff00ff> clientId = client.getSysid();</FONT>

      <FONT color=#ff00ff>%></FONT>

      <FONT color=#ff00ff><!--</FONT>
      <FONT color=#ff00ff> public void insertAlertType(String alertId, String alertName,int</FONT>
      <FONT color=#ff00ff> cardinality,int clientId)</FONT>
      <FONT color=#ff00ff> throws RemoteException, UniqueException, NotFoundException, Exception;</FONT>
      <FONT color=#ff00ff>--></FONT>
      <FONT color=#ff00ff><FORM ACTION="InsertAlertTypeServlet" METHOD=POST onSubmit="return onSubmit(this)"></FONT>
      <FONT color=#ff00ff><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"></FONT>
      <FONT color=#ff00ff> <TR></FONT>
      <FONT color=#ff00ff> <TD ALIGN="LEFT"></FONT>
      <FONT color=#ff00ff><!-- Tittle --></FONT>
      <FONT color=#ff00ff> <CENTER></FONT>
      <FONT color=#ff00ff> <TABLE border="0" cellspacing="2" cellpadding="2" <%=bgcolorWhite%>></FONT>
      <FONT color=#ff00ff> <TR><TH ALIGN="CENTER"><%=fontTitle%>Alert Type</FONT></TH></TR></FONT>
      <FONT color=#ff00ff> </TABLE><BR></FONT>
      <FONT color=#ff00ff> </CENTER></FONT>
      <FONT color=#ff00ff><!-- Main Table --></FONT>
      <FONT color=#ff00ff> <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2"></FONT>
      <FONT color=#ff00ff> <TR ALIGN="CENTER", VALIGN="MIDDLE"></FONT>
      <FONT color=#ff00ff> <TH ALIGN="LEFT" <%=bgcolorTh%>><%=fontTh%></FONT>
      <FONT color=#ff00ff> ID</FONT>
      <FONT color=#ff00ff> </FONT></TH></FONT>
      <FONT color=#ff00ff> <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%></FONT>
      <FONT color=#ff00ff> <INPUT TYPE="TEXT", NAME="alertId", ALIGN="CENTER", MAXLENGTH=50></FONT>
      <FONT color=#ff00ff> </FONT></TD></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff> <TR ALIGN="CENTER", VALIGN="MIDDLE"></FONT>
      <FONT color=#ff00ff> <TH ALIGN="LEFT" <%=bgcolorTh%>><%=fontTh%></FONT>
      <FONT color=#ff00ff> Name</FONT>
      <FONT color=#ff00ff> </FONT></TH></FONT>
      <FONT color=#ff00ff> <TD ALIGN="LEFT" <%=bgcolorTd%>><%=fontTd%></FONT>
      <FONT color=#ff00ff> <INPUT TYPE="TEXT", NAME="name", ALIGN="CENTER", MAXLENGTH=250></FONT>
      <FONT color=#ff00ff> </FONT></TD></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff><!-- CARDINALITY AND PRIORITY, REMOVED FOR NOW, MAY NED LATER</FONT>
      <FONT color=#ff00ff> <TR ALIGN="center", VALIGN="middle"></FONT>
      <FONT color=#ff00ff> <TH ALIGN="LEFT" <%=bgcolorTh%> ><B><FONT face="Verdana, Geneva, Arial" size="-2" color="#000000"></FONT>
      <FONT color=#ff00ff> Cardinality</FONT></TH></FONT>
      <FONT color=#ff00ff> <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%></FONT>
      <FONT color=#ff00ff> &nbsp One-to-One</FONT>
      <FONT color=#ff00ff> <INPUT TYPE="radio", NAME="cardinality", VALUE="1", ALIGN="center", CHECKED></FONT>
      <FONT color=#ff00ff> &nbsp Broadcast</FONT>
      <FONT color=#ff00ff> <INPUT TYPE="radio", NAME="cardinality", VALUE="2", ALIGN="center"></FONT>
      <FONT color=#ff00ff> </TD></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff> <TR ALIGN="center", VALIGN="middle"></FONT>
      <FONT color=#ff00ff> <TH ALIGN="LEFT" <%=bgcolorTh%>><B><FONT face="Verdana, Geneva, Arial" size="-2" color="#000000"></FONT>
      <FONT color=#ff00ff> Priority Code</FONT></TH></FONT>
      <FONT color=#ff00ff> <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%></FONT>
      <FONT color=#ff00ff> &nbsp Nice</FONT>
      <FONT color=#ff00ff> <INPUT TYPE="radio", NAME="priorityCode", VALUE="nice", ALIGN="center"></FONT>
      <FONT color=#ff00ff> &nbsp Normal</FONT>
      <FONT color=#ff00ff> <INPUT TYPE="radio", NAME="priorityCode", VALUE="normal", ALIGN="center", CHECKED></FONT>
      <FONT color=#ff00ff> &nbsp Urgent</FONT>
      <FONT color=#ff00ff> <INPUT TYPE="radio", NAME="priorityCode", VALUE="urgent", ALIGN="center"></FONT>
      <FONT color=#ff00ff> </TD></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff>--></FONT>
      <FONT color=#ff00ff> <INPUT TYPE="HIDDEN", NAME="cardinality", VALUE="1"></FONT>
      <FONT color=#ff00ff> <INPUT TYPE="HIDDEN", NAME="priorityCode", VALUE="urgent"></FONT>
      <FONT color=#ff00ff> </TABLE></FONT>
      <FONT color=#ff00ff> </CENTER></FONT>
      <FONT color=#ff00ff><!-- buttons--></FONT>
      <FONT color=#ff00ff> <CENTER></FONT>
      <FONT color=#ff00ff> <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2" <%=bgcolorWhite%>></FONT>
      <FONT color=#ff00ff> <TR <%=bgcolorWhite%>></FONT>
      <FONT color=#ff00ff> <TD ALIGN="LEFT" ><%=fontTd%>&nbsp</FONT></TD></FONT>
      <FONT color=#ff00ff> <TH ALIGN="right"><%=fontTh%><INPUT TYPE="SUBMIT" NAME="continueSubmit" VALUE="Add Alert Type"></FONT></TH></FONT>
      <FONT color=#ff00ff> <TH ALIGN="right"><%=fontTh%><INPUT TYPE="BUTTON" NAME="cancelButton" VALUE="Cancel" onClick="Cancel()"></FONT></TH></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff> </TABLE></FONT>
      <FONT color=#ff00ff> </CENTER></FONT>
      <FONT color=#ff00ff> <!-- End Inner Table--></FONT>

      <FONT color=#ff00ff> <!--forwardAddress is the url that the servlet returns to --> </FONT>
      <FONT color=#ff00ff> <INPUT TYPE="HIDDEN", NAME="forwardAddress", VALUE="<%= request.getParameter("forwardAddress") %>"></FONT>
      <FONT color=#ff00ff> <!-- why is this here? May be unnecessary?--></FONT>
      <FONT color=#ff00ff> <INPUT TYPE="HIDDEN", NAME="clientId", VALUE="<%=clientId%>"></FONT>
      <FONT color=#ff00ff> </TD></FONT>
      <FONT color=#ff00ff> </TR></FONT>
      <FONT color=#ff00ff></TABLE></FONT>
      <FONT color=#ff00ff></FORM></FONT>

      <FONT color=#ff00ff><BR CLEAR=LEFT></FONT>
      <FONT color=#ff00ff><BR CLEAR=LEFT></FONT>
      <FONT color=#ff00ff><BR CLEAR=LEFT></FONT>

      <FONT color=#ff00ff><%@ include file="/includes/admin_footer.jsp" %></FONT>


      <FONT color=#ff00ff></BODY></FONT>
      <FONT color=#ff00ff></HTML></FONT>

      </PRE>
      </BODY>
      </HTML>

      ....................CUT HERE...........................................

      <!--
      $Header: /disk01/cvsrepos_v3/p3platform/p3c/admininterface/jsp/alert_type.jsp,v 1.3 2000/12/08 18:11:44 pbismuti Exp $
      $Author: pbismuti $
      $Date: 2000/12/08 18:11:44 $
      $Revision: 1.3 $
      -->
      <!-- alert_type.jsp

      This page collects information necessary to create a new Alert Type.
      It is arrived at from 'edit_alerts.jsp' by clicking on the "Add New Alert"
      button at the bottom of the page. The user fills in the new alert "Id" and "Name"
      and then submits the form to the servlet "InsertAlertTypeServlet".
      -->
      <%
      /*
      construct returnAddress - this constructs and stores as a
      session variable the current URL by looping through the
      parameters and building string that can be used as a request
      using the GET method. This is used to create a "back" link
      in the 'admin_error.jsp' page. The string is stored in the variable "return_address".
      */
      // determine returnAddress
      String requestURI = request.getRequestURI();
      String queryString = "";

      // construct query string
      Enumeration params7 = request.getParameterNames();
      String paramName7 = null;
      String[] paramValues7 = null;

      while (params7.hasMoreElements()) {
      paramName7 = (String) params7.nextElement();
      paramValues7 = request.getParameterValues(paramName7);
      for (int i=0; i<paramValues7.length; i++){
      queryString += paramName7+"="+paramValues7[i].toString()+"&";
      }
      }
      if (queryString.length() > 0){
      queryString = queryString.substring(0,queryString.length()-1);
      }

      // now construct return address
      String returnAddress = null;
      returnAddress = requestURI + "?" + queryString;

      // now set a session attribute
      session.removeAttribute("returnAddress");
      session.setAttribute("returnAddress",returnAddress);
      %>

      <HTML>
      <HEAD>
      <TITLE>Alert Type</TITLE>
      <SCRIPT>
      //........................................................................
      function Cancel(){
      location = "/edit_alerts.jsp";
      }
      //........................................................................
      // onSubmit() - do some error checking before the form is submitted.
      //........................................................................
      function onSubmit(form){
      var fc = isNotEmpty("Alert ID",form.alertId.value);
      var lc = isNotEmpty("Name",form.name.value);
      var ai = isNotInside(form.alertId.value,alertIdArray,"alertId");
      var av = isSafeString(form.alertId.value,"ID");
      var ann = isSafeString(form.name.value,"Name");
      var an = isNotInside(form.name.value,alertNameArray,"alertName");
      return (fc&&lc&&ai&&av&&ann&&an);
      }
      //........................................................................
      function isNotEmpty(name,value){
      if (value.length ==0){
      alert("ERROR: "+name+" must be entered.");
      return false;
      }else{
      return true;
      }
      }
      //........................................................................
      function isNotInside(alertData,alertDataArray,type){
      for (var i=0; i<alertDataArray.length; i++){
      if (strip(alertData) == strip(alertDataArray[i])){
      alert("ERROR: the " +type+ " '"+alertData+"' already exists, please choose another.");
      return false;
      }
      }
      return true;
      }
      //........................................................................
      function strip(string){
      string = string.replace(/\s+$/,""); // strip off leading and trailing
      string = string.replace(/^\s+/,"");
      return string;
      }
      //........................................................................
      function isSafeString(s,name) {
      illegalChar="\"'\\&#+";
      goodString = true;
      for (var i=0;i<6;i++) {
      if (s.indexOf(illegalChar.substring(i,i+1))!=-1){
      alert("ERROR: invalid value for " + name+".\nIllegal character detected: '"+illegalChar.substring(i,i+1)+"'.");
      goodString = false;
      }
      }
      return goodString;
      }

      function cleanApostrophe(s){
      var s2 = "";
      for(var i=0;i<s.length;i++){
      var c = s.charAt(i);
      if(c=="'")
      s2 += "\'";
      else
      s2 += c;
      }
      return s2;
      }

      </SCRIPT>
      <BODY BGCOLOR=#FFFFFF ALINK=#0000FF VLINK=#0000FF>
      <%@
      page import="
      p3c.admininterface.ejb.TemplateManager.*,
      p3c.admininterface.ejb.Help.*,
      p3c.admininterface.ejb.*,
      p3c.admininterface.*,
      java.text.*,
      "
      %>
      <%@ include file="/includes/validate_user.jsp" %>
      <%@ include file="/includes/admin_header.jsp" %>

      <%
      // retrieve the request input parameters
      // then define an array in javascript that can be used
      // to check against adding a new alert with an already
      // existing alertId

      out.println("<SCRIPT>");

      java.util.Enumeration params = request.getParameterNames();
      String paramName = null;
      String[] paramValues = null;

      // alertIdArray
      paramName = "alertIdArray";
      paramValues = null;
      out.println(" alertIdArray = [");
      paramValues = request.getParameterValues(paramName);
      for (int i = 0; paramValues != null && i < paramValues.length -1; i++) {
      out.println("\""+paramValues[i].toString() + "\",");
      }
      if(paramValues != null)
      out.println("\""+paramValues[paramValues.length-1].toString() + "\"");
      out.println("];\n");

      // alertNameArray
      paramName = "alertNameArray";
      paramValues = null;
      out.println(" alertNameArray = [");
      paramValues = request.getParameterValues(paramName);
      for (int i = 0; paramValues != null && i < paramValues.length -1; i++) {
      out.println("\""+paramValues[i].toString() + "\",");
      }
      if(paramValues != null)
      out.println("\""+paramValues[paramValues.length-1].toString() + "\"");
      out.println("];\n");

      out.println("</SCRIPT>");

      // just in case
      int clientId;
      clientId = client.getSysid();

      %>

      <!--
      public void insertAlertType(String alertId, String alertName,int
      cardinality,int clientId)
      throws RemoteException, UniqueException, NotFoundException, Exception;
      -->
      <FORM ACTION="InsertAlertTypeServlet" METHOD=POST onSubmit="return onSubmit(this)">
      <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR>
      <TD ALIGN="LEFT">
      <!-- Tittle -->
      <CENTER>
      <TABLE border="0" cellspacing="2" cellpadding="2" <%=bgcolorWhite%>>
      <TR><TH ALIGN="CENTER"><%=fontTitle%>Alert Type</FONT></TH></TR>
      </TABLE><BR>
      </CENTER>
      <!-- Main Table -->
      <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2">
      <TR ALIGN="CENTER", VALIGN="MIDDLE">
      <TH ALIGN="LEFT" <%=bgcolorTh%>><%=fontTh%>
      ID
      </FONT></TH>
      <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%>
      <INPUT TYPE="TEXT", NAME="alertId", ALIGN="CENTER", MAXLENGTH=50>
      </FONT></TD>
      </TR>
      <TR ALIGN="CENTER", VALIGN="MIDDLE">
      <TH ALIGN="LEFT" <%=bgcolorTh%>><%=fontTh%>
      Name
      </FONT></TH>
      <TD ALIGN="LEFT" <%=bgcolorTd%>><%=fontTd%>
      <INPUT TYPE="TEXT", NAME="name", ALIGN="CENTER", MAXLENGTH=250>
      </FONT></TD>
      </TR>
      <!-- CARDINALITY AND PRIORITY, REMOVED FOR NOW, MAY NED LATER
      <TR ALIGN="center", VALIGN="middle">
      <TH ALIGN="LEFT" <%=bgcolorTh%> ><B><FONT face="Verdana, Geneva, Arial" size="-2" color="#000000">
      Cardinality</FONT></TH>
      <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%>
        One-to-One
      <INPUT TYPE="radio", NAME="cardinality", VALUE="1", ALIGN="center", CHECKED>
        Broadcast
      <INPUT TYPE="radio", NAME="cardinality", VALUE="2", ALIGN="center">
      </TD>
      </TR>
      <TR ALIGN="center", VALIGN="middle">
      <TH ALIGN="LEFT" <%=bgcolorTh%>><B><FONT face="Verdana, Geneva, Arial" size="-2" color="#000000">
      Priority Code</FONT></TH>
      <TD ALIGN=LEFT <%=bgcolorTd%>><%=fontTd%>
        Nice
      <INPUT TYPE="radio", NAME="priorityCode", VALUE="nice", ALIGN="center">
        Normal
      <INPUT TYPE="radio", NAME="priorityCode", VALUE="normal", ALIGN="center", CHECKED>
        Urgent
      <INPUT TYPE="radio", NAME="priorityCode", VALUE="urgent", ALIGN="center">
      </TD>
      </TR>
      -->
      <INPUT TYPE="HIDDEN", NAME="cardinality", VALUE="1">
      <INPUT TYPE="HIDDEN", NAME="priorityCode", VALUE="urgent">
      </TABLE>
      </CENTER>
      <!-- buttons-->
      <CENTER>
      <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2" <%=bgcolorWhite%>>
      <TR <%=bgcolorWhite%>>
      <TD ALIGN="LEFT" ><%=fontTd%> </FONT></TD>
      <TH ALIGN="right"><%=fontTh%><INPUT TYPE="SUBMIT" NAME="continueSubmit" VALUE="Add Alert Type"></FONT></TH>
      <TH ALIGN="right"><%=fontTh%><INPUT TYPE="BUTTON" NAME="cancelButton" VALUE="Cancel" onClick="Cancel()"></FONT></TH>
      </TR>
      </TABLE>
      </CENTER>
      <!-- End Inner Table-->

      <!--forwardAddress is the url that the servlet returns to -->
      <INPUT TYPE="HIDDEN", NAME="forwardAddress", VALUE="<%= request.getParameter("forwardAddress") %>">
      <!-- why is this here? May be unnecessary?-->
      <INPUT TYPE="HIDDEN", NAME="clientId", VALUE="<%=clientId%>">
      </TD>
      </TR>
      </TABLE>
      </FORM>

      <BR CLEAR=LEFT>
      <BR CLEAR=LEFT>
      <BR CLEAR=LEFT>

      <%@ include file="/includes/admin_footer.jsp" %>


      </BODY>
      </HTML>



      ....................CUT HERE...........................................
    Your message has been successfully submitted and would be delivered to recipients shortly.