This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Table data display with JSTL in a JSP  RSS feed

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using JSTL <c:forEach> to iterate rows from a table and display on a page. I need a hyperlink for one column value.

My code is as follows:

<table border="1">
<%-- Get the column names for the header of the table --%>
<c:forEach var="columnName" items="${abc.columnNames}">
<th><c ut value="${columnName}"/></th>
</c:forEach>
<br>

<%-- Get the value of each column while iterating over rows --%>
<c:forEach var="row" items="${abc.rows}">
<tr>
<c:forEach var="column" items="${row}">
<td><c ut value="${column.value}" /></td>
</c:forEach>
</tr>
</c:forEach>
</table>

Any pointers on how to go about it.

SP Nam
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SP, with 35 posts to the Ranch you should know by now to enclose your code in UBB code tags (you can enter them by hand or use the CODE button below the topic entry area), and to click the 'disable smilies' checkbox to keep your <cut> tags from looking so surprised.

With regards to your question, you create a link using an <a> tag just like in any other page. The rules of HTML don't change just because you are generating the page with JSP/JSTL.
[ October 27, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It also looks like you forgot the <tr> tag to enclose the first row of <th> tags.
 
SP Nam
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear
I need <a> tag for one column value, when I put <a> with my code it is taking hyper link for all values.

Any code snippet Please

SP Nam
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As stated earlier by Bear, using the anchor tag in a JSP page is no different than a normal html web page.

Each anchor tag must be terminated with a </a> tag.

For example
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

it is taking hyper link for all values.



If I am understanding this correctly -- which I may not be -- you are saying that you only want certain rows to be links based upon some criteria?

If so, then think of it just the same as you would a similiar issue in Java. If you are iterating through some data, and want to take special action only under certain conditions, then you would test for that condition using an if statement. Same deal applies here: use <c:if> to determine when to include the link markup.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!