Solved

playing with jstl

Posted on 2007-04-04
7
396 Views
Last Modified: 2008-01-09
hi guys

I have something like this

<table>

<c:forEach var="docsummparty" items="${documentSummary.arrayList}" varStatus="DocPartycount">
               <tr valign="top" bgcolor="#ffffff">
            <td nowrap valign="top">


                 <c:out value='${DocPartycount.count}'/>
                    
               </td>
          </tr>
</c:forEach>
</table>



Now in the above code  the line " <c:out value='${DocPartycount.count}'/> "  displays the count number like 1 or 2 or 3.
Now, Instead of displaying the numbers like 1 or 2 or 3 , i want to display a, b, c, d, ..and so on.

I want to know if thats possible

Any help will be greatly appreciated

thanks in advance
Jay
0
Comment
Question by:jaggernat
  • 3
  • 2
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Manish
ID: 18852148
I don't think , it is possible. You can compare with number and print a,b,c..
0
 
LVL 10

Author Comment

by:jaggernat
ID: 18852223
>>>You can compare with number and print a,b,c..

the same thing need to be done using  JSTL tags
0
 
LVL 11

Accepted Solution

by:
Manish earned 150 total points
ID: 18862483
I think, you can create list which contains a...z .
And access value from list by passing count..
<c:out value='${list[DocPartycount.count]}'/>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Assisted Solution

by:rrz
rrz earned 100 total points
ID: 18869642
Points to  karanw.  
Here is an example.  
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
  String[] alpha = {"a","b","c","d","e"};
  request.setAttribute("alpha",alpha);
%>
<c:forEach var="docsummparty" items="jim,sam,ann,sally,jane" varStatus="DocPartycount">
                 ${alpha[DocPartycount.count - 1]}    
</c:forEach>
0
 
LVL 10

Author Comment

by:jaggernat
ID: 18870241
thanks both of you, i dint know you can print stuff out of an array in jstl, thats cool.

however
<%
  String[] alpha = {"a","b","c","d","e"};
  request.setAttribute("alpha",alpha);
%>
is there anyway i can represent the above code in jstl tags
something like  <c:set var="Array" value="['a', 'b', 'c....']"   scope="request" /> //not sure if this is correct..

any comments appreciated,
thanks guys
J
0
 
LVL 27

Expert Comment

by:rrz
ID: 18870828
>is there anyway i can represent the above code in jstl tags
I don't know how to do that. Maybe karanw knows a way. If you trying to avoid scriptlets then the easiest way would to use "tag files" . I assume you are using JSP 2.0 .
http://today.java.net/pub/a/today/2003/11/14/tagfiles.html
http://www.google.com/search?hl=en&q=%22tag+files%22+jsp
0
 
LVL 11

Expert Comment

by:Manish
ID: 18874558
No, I dont think it is possible.You have to create list and it should be in scope.
If you are using any bean, then you can transfer this code to bean
and get that list
like ${bean.abclist}  in jsp.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now