?
Solved

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

Posted on 2007-03-30
11
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 28

Expert Comment

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

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

 
LVL 28

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 1000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 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