Solved

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

Posted on 2007-03-30
11
270 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
Comment Utility
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:mayankeagle
Comment Utility
What is the problem you are facing?
0
 
LVL 27

Expert Comment

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

Expert Comment

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

Expert Comment

by:Kuldeepchaturvedi
Comment Utility
:-) not a problem..... happens with all of us...:-)
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:huzefaq
Comment Utility
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
Comment Utility
put the counter and give width as per your requirement.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
Comment Utility
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:mayankeagle
Comment Utility
>> <td width="100">  </td>

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

Author Comment

by:huzefaq
Comment Utility
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
Comment Utility
<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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Updating Java 9 86
pairs challenge 5 44
Securing Jmx Console and web console 2 45
Java Timer (static) 9 5
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

763 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

10 Experts available now in Live!

Get 1:1 Help Now