Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting JSP error in if else block

    Code below:


    <body >
    <!-- <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="248" height="20"><img src="images/top1.jpg" width="248" height="97" /></td>
    <td width="100%" background="images/top2BG.jpg">&nbsp;</td>
    <td width="214" align="right"><img src="images/Top3.jpg" width="214" height="97" /></td>
    </tr>
    </table>-->
    <s:form id="trafficCodeForm" name="trafficCodeForm" method="post" onsubmit="return validateForm(this);" action="createTCMAction">
    <div style="width: 100%" scrollings="none">

    <table width="100%" height="445" border="0" cellpadding="0"
    cellspacing="0">
    <tr>
    <td valign="top" bgcolor="#FFFFFF">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="4%"><img src="images/corner.jpg" width="40"
    height="40" /></td>
    <td width="96%" class="boldblacktext">Add Details
    <!-- Enhancement for Replace and Modify Screen
    <a style="float:right" href="/TCM/LogoutServlet">Log Out</a>-->
    <br/>&nbsp;<p align="center" style="color:red;" ><b><br/>${param.error}</b></p></td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <table width="666" border="0" cellpadding="0" cellspacing="0"
    id="table2" align="center">
    <tr>
    <td width="167" height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator
    Code</td>
    <td width="497" align="left" class="normaltext2" ><input id="operatorCode" name="operatorCode" type="text"
    class="normaltext" title="Operator Code" maxlength="10" /></td>
    </tr>
    <tr>
    <td height="25" align="left" bgcolor="#F7F7F7" class="normaltext2">Event
    Classification</td>
    <td class="normaltext2" align="left"><select id="eventClassification" name="eventClassification"
    title="Event Classification" class="normaltext">
    <%for (int i=0;i<eventClassificationlist.size();i++) {
    String code = (String)eventClassificationlist.get(i);
    %>
    <option value="<%=i%>" <%if (i == 0) {%>selected<%}%>><%=code%></option>
    <% } %>
    </select></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">IMSI
    Code Series</td>
    <td class="normaltext2" align="left"><input id="imsiCodeSeries" name="imsiCodeSeries"
    type="text" class="normaltext" title="IMSI Code Series" maxlength="15"/></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator
    Type</td>
    <td class="normaltext2" align="left">
    <select id="operatorType" name="operatorType" title="Operator Type" onchange="disableCity()" class="normaltext">
    <option value="0">--Select--</option>
    </select></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">First
    Call Classification</td>
    <td class="normaltext2" align="left"><input id="firstCallClassification" name="firstCallClassification"
    type="text" class="normaltext" title="First Call Classification" value="1"/></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator
    Country</td>
    <td class="normaltext2" align="left"><select id ="operatorCountry" name="operatorCountry"
    class="normaltext" onchange="disableCircle(this)">
    <%for (int i=0;i<countryList.size();i++) {
    String code = (String)countryList.get(i);
    %>
    <option value="<%=code%>" <%if (i == 0) {%>selected<%}%>><%=code%></option>
    <% } %>
    </select></td>
    </tr>
    <tr>
    </tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator Circle</td>
    <td class="normaltext2" align="left"><select id="operatorCircle" name="operatorCircle"
    title="Operator Circle" class="normaltext">


    <%for (int i=0;i<circlelist.size();i++) {
    if(i==4)
    continue;
    String code = (String)circlelist.get(i);
    %>
    <option value="<%=i%>" <%if (i == 0) {%>selected<%}%>><%=code%></option>
    <% } %>
    </select>
    </td>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator
    City</td>
    <td class="normaltext2" align="left"><input id="operatorCity" name="operatorCity"
    type="text" class="normaltext" title="Operator City" maxlength="21"/></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Operator
    Name</td>
    <td class="normaltext2" align="left"><input id="operatorName" name="operatorName"
    type="text" class="normaltext" title="Operator Name" maxlength="50"/></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Event
    Region</td>
    <td class="normaltext2" align="left"><input id="eventRegion" name="eventRegion" type="text"
    class="normaltext" title="Event Region" maxlength="21"/></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">Distance
    Band</td>
    <td class="normaltext2" align="left"><select id="distanceBand" name="distanceBand" title="Distance Band" class="normaltext">



    <%for (int i=0;i<distanceBandList.size();i++) {
    // String code = (String)hsdistanceBand.get("27");
    String code = (String)distanceBandList.get(i);
    %>
    <option value="<%=code%>" <%if (i == 0) {%>selected<%}%>><%=code%></option>


    <% } %>

    </select></td>
    </tr>
    <tr>
    <td height="25" bgcolor="#F7F7F7" class="normaltext2" align="left">LRN</td>
    <td class="normaltext2" align="left"><input id="lrn" name="lrn" type="text"
    class="normaltext" title="LRN" /></td>
    </tr>

    <tr>
    <td height="25" colspan="2" align="center" class="normaltext2">
    <table width="124" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><input id="Review" name="Submit" type="submit" class="Button"
    value="Review"/></td>
    <td>&nbsp;</td>
    <td>
    <input name="Submit2" type="button" class="Button" value="Reset"
    onclick="functionReset();" />
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>


    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    </table>
    </td>
    </tr>
    <% } else { %>
    <tr><td>
    <script type="text/javascript">
    parent.location.href = 'login.jsp';
    </script>
    </td></tr>
    <% return ;}%>
    </table>
    </div>
    <input id="hiddenCode" name="hiddenCode" type="hidden" class="normaltext" title="Hidden Code" maxlength="10" />
    <input id="hiddenCodeEvent" name="hiddenCodeEvent" type="hidden" class="normaltext" title="Hidden Code Event" maxlength="30" />
    <input id="hiddenCodeCircle" name="hiddenCodeCircle" type="hidden" class="normaltext" title="Hidden Code Circle" maxlength="30" />
    </s:form>
    <!-- <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="20" background="images/Bottom-BG.jpg">&nbsp;</td>
    </tr>
    </table>-->
    </body>
    </html>


    Getting error in else bock-- Syntax error on token "else", delete this token

    Please suggest whjat the issue. If I am replacing <s:form>(struts tag) wit normal form <form> , the error is not coming.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,925
    Thanks
    46
    Thanked 203 Times in 202 Posts
    Please format you code in the future... The problem is you brace. I'm not sure if you want the else within the for loop or not, but as of now you close the for loop, and omit the else, and then the else has no leading if statement.

    Code:
    <%for (int i=0;i<distanceBandList.size();i++) {
    // String code = (String)hsdistanceBand.get("27");
    String code = (String)distanceBandList.get(i);
    %>
    <option value="<%=code%>" <%if (i == 0) {%>selected<%}%>><%=code%></option>
    
    
    <% } %>
    
    
    <% } else { %>
    <tr><td>
    <script type="text/javascript">
    parent.location.href = 'login.jsp';
    </script>
    </td></tr>
    <% return ;}%>

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •