Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to avoid scriplets in jsp ?

Reply
Thread Tools

how to avoid scriplets in jsp ?

 
 
Hiren
Guest
Posts: n/a
 
      08-20-2003
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
 
Reply With Quote
 
 
 
 
Tim Slattery
Guest
Posts: n/a
 
      08-20-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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><cut value="${werke.id}" /></td>
<td><cut value="${werke.name}" /></td>
</tr>
</c:forEach>

--
Tim Slattery
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      08-20-2003
(E-Mail Removed) (Hiren) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid having a SQL express for web parts and avoid personalization Roger23 ASP .Net 2 10-12-2006 10:54 PM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
Avoid wasting time or how to avoid initialization Alexander Malkis C++ 8 04-13-2004 11:23 PM
Avoid JSP probe scripting of your forms with image validation servlet Andreas Bednarz Java 0 04-12-2004 07:26 PM
Why are JSP tags considered as being less logic than scriplets ReplyToNewsgroup_NoSpamWanted@bahnhofbredband.se Java 4 11-26-2003 05:40 AM



Advertisments