Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   how to avoid scriplets in jsp ? (http://www.velocityreviews.com/forums/t125833-how-to-avoid-scriplets-in-jsp.html)

Hiren 08-20-2003 02:46 PM

how to avoid scriplets in jsp ?
 
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

Tim Slattery 08-20-2003 04:58 PM

Re: how to avoid scriplets in jsp ?
 
hvdossani@rogers.com (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:out value="${werke.id}" /></td>
<td><c:out value="${werke.name}" /></td>
</tr>
</c:forEach>

--
Tim Slattery
Slattery_T@bls.gov

Jeff 08-20-2003 06:36 PM

Re: how to avoid scriplets in jsp ?
 
hvdossani@rogers.com (Hiren) wrote in message news:<5325374c.0308200646.26179685@posting.google. com>...
> 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/str...c.html#iterate


All times are GMT. The time now is 01:33 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.