In my JSP page I am fetching values from a sql statement in a ArrayList, which is getting created as table content. a set of values in this list would be a url. How can I convert this particular td element (the one with url) to be a hyperlink action item?
Here is the jsp code
<table border="1" id="tableView">
<thead>
<th></th><th>ID</th><th>Name</th><th>Description</th><th>Active</th><th>Release Date</th><th>Url</th>
</thead>
<tbody>
<%
if(max==0)
{
%><tr><td></td><td colspan="5" class="viewa"><% out.println("No Records found."); %></td><%
}
else
{
for(int i=0;i<result.size();i++)
{
%><tr><td><input class="tablechkbox" type="radio" name="prodAlertsRad"/></td><%
List r=new ArrayList();
r=(List)result.get(i);
for(int j=0;j<r.size();j++)
{
%><td class="viewa"><%out.print(r.get(j));%></td><%
}
%></tr><%
}
}
%>
</tbody>
</table>
You can test it here jsfiddle
You need to make change in this part of your code.
to make your url work as hyperlink, you need to use anchor tag inside ur
td. Also, it is important to know the exact index where yoururllies in the listr. Since in your case, url is at the last index, we can modify the code this way-you might need to do little handling to avoid
indexOutOfBoundException. I leave it for u to do that 🙂