• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to convert Java ArrayList code to JSTL

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends

1.I want to know, how to convert Java ArrayList codes in JSTL.

I written scriplet code in my jsp. In that scriplets i am getting the arrylist, and using the arraylist i am executing for loops.

Now I am moving to JSTl for readability of code and avoiding scriplets.

I dont know how to use the java Arraylist code in JSTL. Please suggest me how to use.


2. How to pass the JSTL Values to User defined XML tags.

Please suggest me to solve the problem.

Thanks in advance
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vasanthan Ramakrishnan:
1.I want to know, how to convert Java ArrayList codes in JSTL.

Do you have a copy of the JSTL Specification? Look up <c:forEach>.

2. How to pass the JSTL Values to User defined XML tags.

I don't know what you mean by JSTL values. The JSTL is just a tag library. Do you mean scoped variables?

Also, what do you mean by "XML tag"?
[ January 23, 2008: Message edited by: Bear Bibeault ]
 
Vasanthan Ramakrishnan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply
1. ok i am using for each.

I need how to assign the list value into JSTL varriable.

for example.

the arraylist values alist=[90,administrator,admin,a@yahoo.com,99,administrator1,admin1,a1@yahoo.com]

I need this output in HTML

Dept Code : 90 Deptname : administrator
Dept Manager: admin Deptmail : a@yahoo.com

Dept Code : 99 Deptname : administrator1
Dept Manager: admin1 Deptmail : a1@yahoo.com

I am written the code in JSTL

<c:forEach var="alist" items="${alist}" begin="0" end="${asize}" step="4">
<TR>
<TD>Det code : </TD>
<TD>${alist[0]} </TD>
<TD>Dept Name: </TD>
<TD>${alist[1]} </TD>
</TR>

<TR>
<TD>Dept Manager: </TD>
<TD>${alist[2]} </TD>
<TD>Dpt Mail: </TD>
<TD>${alist[3]} </TD>
</TR>
</c:forEach>

here asize is the array list size.

My Output

Dept Code : 90 Deptname : administrator
Dept Manager: admin Deptmail : a@yahoo.com

Dept Code : 90 Deptname : administrator
Dept Manager: admin Deptmail : a@yahoo.com

I know when i given alist[0],alist[1],alist[2],alist[3], it will print the same.


I dont know how to reteive the next iterate value. So only i just give the direct index value.

How to reterive the next value in for each. like in java scriplet code.

like this
<%for(int i=0;i<alist.size();i++) {
String str = String.valueOf(alist.get(i));
String str1 = String.valueOf(alist.get(i+1));// how to do this in JSTL
%>

<TD>STR - <%=str%> </TD>
<TD>STR1 - <%=str1%> </TD>

<% } %>

Please Suggest how to do this.

2.how to use JSTL varriable into Xml Tag.

for example

In my TLD File(eztaglib.tld)

<tag>
<name>companytag</name>
<tag-class>bas.CompanyTag</tag-class>
<attribute>
<name>dbase</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>dbpass</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>dburl</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>pgm_sname</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>session</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>

</tag>


old code :
java value I am passing to XML in jsp scriplet code.

<%@ taglib uri="/ezerptags.tld" prefix="eztag" %>
.......
....
<eztag:companytag pgm_sname="<%= strpgm_name%>" dbase="<%= strd%>"
dbpass="<%= strp%>" dburl="<%= stru%>" session="<%= session%>" />
....
...

After modified in JSTL

<%@ taglib uri="/ezerptags.tld" prefix="eztag" %>
.......
....
<eztag:companytag pgm_sname="${pgm_name}" dbase="${strd}"
dbpass="${strp}" dburl="${stru}" session="${session}" />
.....
...

but its Not working. How to use this

the "eztag" and "companytag" are the customtag. these tages available in eztaglib.tld file. I am passing the value through XML Tag.

but its Not working. How to use this

Thanks in advance
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic