Solved

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

Posted on 2007-03-30
11
278 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
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.

 
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
 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 107
Java - Why doesn't this JFrame work 3 59
Desingning Refactoring existing code 2 24
How to determine if a string is a valid SHA value 7 33
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

777 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