how to avoid scriplets in jsp ?

H

Hiren

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.
 
T

Tim Slattery

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>
 
J

Jeff

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top