Search code examples
jspservletsscriptlet

Why i am getting Syntax error on tokem "<td>" , delete this token in my JSP?


i am trying to retrieve db table data into table but i am getting syntax error at

<body>
      <tr>
         if(!resultset.next()) {
              out.println("Sorry, could not find that publisher. ");
           } else {     
            while(resultset.next())
            {
            <tr>
            <td class="auto-style9"><%=resultset.getInt(1)%> </td> 
            <td class="auto-style10"><%=resultset.getString(2)%></td>
            <td class="auto-style11"><%=resultset.getString(3)%></td>
            <td class="auto-style11"><%=resultset.getString(4)%></td>
        </tr>   
            }
           } 
     %>
      </table>
</body>

Solution

  • You mixed html code with jsp code.

    It should be :

    <%
    if(!resultset.next()) {
        out.println("Sorry, could not find that publisher. ");
    } else {
        while(resultset.next())
        {
    %>
        <tr>
            <td class="auto-style9"><%=resultset.getInt(1)%> </td> 
            <td class="auto-style10"><%=resultset.getString(2)%></td>
            <td class="auto-style11"><%=resultset.getString(3)%></td>
            <td class="auto-style11"><%=resultset.getString(4)%></td>
        </tr>
    <%
        }
    } 
    %>
    </table>