Sallyerik
Sallyerik

Reputation: 519

<a href using variable in jsp

I'm trying to include a link in one element which is within a table.

When I do the link without it's working fine, however when I want to include it as a part of the table it doesn't work.

This line of code works:

for(int i=0;i<tableWeb.size();i++){
  TableBody t=(TableBody)tableWeb.get(i);%>
    <a href="Controller?operation=<%=t.getString1()%>"><%=t.getString1()%></a> 
<%}%>

This line of code fail:

for(int i=0;i<tableWeb.size();i++){
   TableBody t=(TableBody)tableWeb.get(i);%>
     <tr><td><a href="Controller?operation=<%=t.getString1()%>"><%=t.getString1()%></a></td></tr> 
<%}%>

It seems like the variable part isn't been recognice.

Could somebody tell me what I'm doing wrong?

thanks

Upvotes: 0

Views: 4480

Answers (1)

Ilya
Ilya

Reputation: 29693

Table body structure should be

<tbody>
  <tr>
   <td> ... </td>
   <td> ... </td>
 </tr>
</tbody>  

Place <tr> outside of for-loop

<tr>  
  for(int i=0;i<tableWeb.size();i++){
    TableBody t=(TableBody)tableWeb.get(i);%>
      <td>
        <a href="Controller?operation=<%=t.getString1()%>"><%=t.getString1()%></a>
      </td> 
  <%}%>
</tr>

Upvotes: 1

Related Questions