Solved

playing with jstl

Posted on 2007-04-04
7
400 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 48
spring dependency injection using java config 2 89
nested if has else if 13 96
Looking for some programs to resell or buy source codes 1 77
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
Read about why it is more lucrative for an IT company to participate in government projects.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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