tags:

views:

483

answers:

2

HI..

I m creating a Jsp custom tag, that should take an array object in the custom tag and it should display the elements of the tag in the HTML table form. Do anyone have the suggestion kindly helpful.

Thanks and regards. Vinayak

+1  A: 

Do you mean something like displayTag? That can form tables out of lists of objects.

Phill Sacre
Yea exactly.. but I dont want to add the display display.jar to my application I want to create it by my own.. yea got it now.. Thanks for ur kind sugestion.regards,Vinayak
Vinayak.B
+1  A: 

As Phill mentioned, the Display Tag taglib is very good for this, but it's actually really easy to do using JSTL:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
.
.
.
<table summary="">
  <thead>
    <tr>
      <th>Property 1</th>
      <th>Property 2</th>
    </tr>
  </thead>
  <tbody>
  <c:forEach var="item" items="${someArrayObject}">
    <tr>
      <td><c:out value="${item.property1}" /></td>
      <td><c:out value="${item.property2}" /></td>
    </tr>
  </c:forEach>
  </tbody>
</table>

Depending on your needs, a custom taglib may be overkill.

John Topley
Yea..It works but I wanted it without using the JSTL, yea got it now.. Thanks for ur kind sugestion. regards, Vinayak
Vinayak.B