Solved

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

Posted on 2007-03-30
11
281 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 27

Expert Comment

by:rrz
ID: 18827646
Your code already does what you have requested in your question.  Please restate your question.
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 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