how to avoid scriplets in jsp ?

Discussion in 'Java' started by Hiren, Aug 20, 2003.

  1. Hiren

    Hiren Guest

    hello,

    i am using following code in my jsp.
    how to avoid the code inside the scriptlet and use tag library ?
    <%
    ArrayList beanCollection =(ArrayList) request.getAttribute("list");

    %>
    <table>
    <logic:iterate id="werke" collection="<%= beanCollection%>">
    <tr>
    <td><bean:write name="werke" property="id" /></td>
    <td><bean:write name="werke" property="name" /></td>

    </tr>
    </logic:iterate>

    thanks for all your help.

    --
    hiren
    Hiren, Aug 20, 2003
    #1
    1. Advertising

  2. Hiren

    Tim Slattery Guest

    (Hiren) wrote:

    >hello,
    >
    >i am using following code in my jsp.
    >how to avoid the code inside the scriptlet and use tag library ?
    > <%
    > ArrayList beanCollection =(ArrayList) request.getAttribute("list");
    >
    > %>
    > <table>
    ><logic:iterate id="werke" collection="<%= beanCollection%>">
    ><tr>
    > <td><bean:write name="werke" property="id" /></td>
    > <td><bean:write name="werke" property="name" /></td>
    >
    ></tr>
    ></logic:iterate>


    How about JSTL:

    <c:forEach items="${list}" var="werke" >
    <tr>
    <td><c:eek:ut value="${werke.id}" /></td>
    <td><c:eek:ut value="${werke.name}" /></td>
    </tr>
    </c:forEach>

    --
    Tim Slattery
    Tim Slattery, Aug 20, 2003
    #2
    1. Advertising

  3. Hiren

    Jeff Guest

    (Hiren) wrote in message news:<>...
    > hello,
    >
    > i am using following code in my jsp.
    > how to avoid the code inside the scriptlet and use tag library ?
    > <%
    > ArrayList beanCollection =(ArrayList) request.getAttribute("list");
    >
    > %>
    > <table>
    > <logic:iterate id="werke" collection="<%= beanCollection%>">
    > <tr>
    > <td><bean:write name="werke" property="id" /></td>
    > <td><bean:write name="werke" property="name" /></td>
    >
    > </tr>
    > </logic:iterate>
    >
    > thanks for all your help.


    use

    <logic:iterate id="werke" name="list" >

    this will look for a bean in any scope named list that can be iterated over

    go here for an explanation of the logic tag...

    http://jakarta.apache.org/struts/struts-logic.html#iterate
    Jeff, Aug 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    514
    Ajay Patil
    Nov 26, 2003
  2. Andreas Bednarz
    Replies:
    0
    Views:
    466
    Andreas Bednarz
    Apr 12, 2004
  3. Alexander Malkis
    Replies:
    8
    Views:
    507
    Alexander Malkis
    Apr 14, 2004
  4. Replies:
    0
    Views:
    4,331
  5. Roger23
    Replies:
    2
    Views:
    983
    Roger23
    Oct 12, 2006
Loading...

Share This Page