Solved

using JSTL how to put data in different <td> tags

Posted on 2007-03-30
11
277 Views
Last Modified: 2013-11-24
Hi Guys

I have a JSTL code which separates a String  using the delimeter (,) and put the data in one <td>
But what I need is that the separated data be placed in different <td>

Any help will be greatly appreciated
Thanks


<tr>
   <c:forTokens items="${elements}" delims="," var="current">
   <td align="center" class="alt-color" >
       <c:out value="${current}" />
   </td>
   </c:forTokens>
</tr>
0
Comment
Question by:huzefaq
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18827641
the code that u have written there should be doing it already..!
<tr>
   <c:forTokens items="${elements}" delims="," var="current">
   <td align="center" class="alt-color" >
       <c:out value="${current}" />
   </td>
   </c:forTokens>
</tr>
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18827643
What is the problem you are facing?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18827646
Your code already does what you have requested in your question.  Please restate your question.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18827648
Sorry, Kuldeepchaturvedi,  I didn't see your comments.  
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18827653
:-) not a problem..... happens with all of us...:-)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:huzefaq
ID: 18827859
Guys you are right it actually does what I was trying to do.

But there is another small problem, what I need is to manage the width of different table columns
For example the <td> should be like this
<td width="100">  </td>
<td width="400">  </td>
<td width="150">  </td>

Would you guys know how can I do this, beacuse right now I am not able to set the width of different columns. Thanks
0
 
LVL 11

Expert Comment

by:Manish
ID: 18828255
put the counter and give width as per your requirement.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18828289
from where these width numbers are suppose to come? is it hard coded? or they are coming from the collection itself?

you need to give us a little more detail so that we can provide the right logic for the same..:-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18829123
>> <td width="100">  </td>

BTW put it as a percentage, not absolute value.
0
 

Author Comment

by:huzefaq
ID: 18830077
Actually to the following code this line is passed

56, this a kitchen ware, 62C

<c:forTokens items="${elements}" delims="," var="current">
   <td align="center" class="alt-color" >
       <c:out value="${current}" />
   </td>
   </c:forTokens>

now this code puts the three different values in three different td's but I need to hard code the width. For the first column 200 px, For the second 400 px and for the third 150 px.

Thanks guys for all your help
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 250 total points
ID: 18830697
<c:forTokens items="${elements}" delims="," var="current" varStatus="sts">
<c:if test ="${sts.count==1}">  
<td width = "200px" align="center" class="alt-color" >
</c:if>
<c:if test ="${sts.count==2}">  
<td width = "400px" align="center" class="alt-color" >
</c:if>
<c:if test ="${sts.count==3}">  
<td width = "150px" align="center" class="alt-color" >
</c:if>
       <c:out value="${current}" />
   </td>
   </c:forTokens>

I know its ugly code, but with given information, this the best that can be done...:-)
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

Title # Comments Views Activity
Requested array size exceeds VM limit 3 85
maven example error 3 54
nextBoolean(double p) for Random class 3 35
how to add new optional parameter to JSP 1 29
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

863 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

21 Experts available now in Live!

Get 1:1 Help Now