JSP: Creating Dynamic Tables

Tables are everywhere! HTML Tables, that is. Learn how to Create dynamic tables using JSP.

provided by: 
Originally published at Internet.com


Generating dynamic content in Web applications is important when the content must reflect the most current and available data and personalized information. One of the main advantages of JavaServer Pages is the ability to generate dynamic content.

Many Web sites depend on the ability to generate tables dynamically, which consists of controlling the TR and TD tags within a TABLE. The online stock portfolio mentioned earlier is a good example where dynamic tables are useful.

The following example shows how to generate five rows without having to code each one of them:
<% for(int row=1; row <= 5; row++) { %>


<% } %>


Ten columns can be added for each row by nesting another for loop within the TR tag as follows:
<% for(int row=1; row <= 5; row++) { %>

<% for(int col=1; col<=10; col++) { %>

<% } %>

<% } %>
(<%=col%>, <%=row%>)


Each cell contains its row and column numbers as the tuple (col, row).

The following listing shows how tables can be generated dynamically. The JSP provides two INPUT fields to define the width and height of the dynamic table. When the user submits the form, the JSP processes the request and generates the table on-the-fly. Each cell of the table has a unique background color and text based on the row and column of the cell...

Read article at Internet.com site
Related Articles
- Diary of a Developer: Send Me Your Questions
We launch an advice column for those trying to keep up with the shock of the new in Web software development. Our columnist offers to answer inquiries on the fundamentals of working with today's wealth of Web technologies. Take him up on his offer.
- Paul Kimmel on VB/VB .NET : Creating Visual Studio .NET Add-Ins
- JSP: Creating a Configurable Home Page
- Creating a Drop-down Menu
- On the Security of PHP, Part 1
- File Permissions
- JSP: Creating Dynamic Titles
- JSP: Creating Dynamic Forms
- ADO is AOK (a simple ADO tutorial)
- Excerpt: Introducing ColdFusion
Regional Articles
- JSP: Creating Dynamic Tables Alabama
- JSP: Creating Dynamic Tables Alaska
- JSP: Creating Dynamic Tables Arizona
- JSP: Creating Dynamic Tables Arkansas
- JSP: Creating Dynamic Tables California
- JSP: Creating Dynamic Tables Colorado
- JSP: Creating Dynamic Tables Connecticut
- JSP: Creating Dynamic Tables DC
- JSP: Creating Dynamic Tables Delaware
- JSP: Creating Dynamic Tables Florida
- JSP: Creating Dynamic Tables Georgia
- JSP: Creating Dynamic Tables Hawaii
- JSP: Creating Dynamic Tables Idaho
- JSP: Creating Dynamic Tables Illinois
- JSP: Creating Dynamic Tables Indiana
- JSP: Creating Dynamic Tables Iowa
- JSP: Creating Dynamic Tables Kansas
- JSP: Creating Dynamic Tables Kentucky
- JSP: Creating Dynamic Tables Louisiana
- JSP: Creating Dynamic Tables Maine
- JSP: Creating Dynamic Tables Maryland
- JSP: Creating Dynamic Tables Massachusetts
- JSP: Creating Dynamic Tables Michigan
- JSP: Creating Dynamic Tables Minnesota
- JSP: Creating Dynamic Tables Mississippi
- JSP: Creating Dynamic Tables Missouri
- JSP: Creating Dynamic Tables Montana
- JSP: Creating Dynamic Tables Nebraska
- JSP: Creating Dynamic Tables Nevada
- JSP: Creating Dynamic Tables New Hampshire
- JSP: Creating Dynamic Tables New Jersey
- JSP: Creating Dynamic Tables New Mexico
- JSP: Creating Dynamic Tables New York
- JSP: Creating Dynamic Tables North Carolina
- JSP: Creating Dynamic Tables North Dakota
- JSP: Creating Dynamic Tables Ohio
- JSP: Creating Dynamic Tables Oklahoma
- JSP: Creating Dynamic Tables Oregon
- JSP: Creating Dynamic Tables Pennsylvania
- JSP: Creating Dynamic Tables Rhode Island
- JSP: Creating Dynamic Tables South Carolina
- JSP: Creating Dynamic Tables South Dakota
- JSP: Creating Dynamic Tables Tennessee
- JSP: Creating Dynamic Tables Texas
- JSP: Creating Dynamic Tables Utah
- JSP: Creating Dynamic Tables Vermont
- JSP: Creating Dynamic Tables Virginia
- JSP: Creating Dynamic Tables Washington
- JSP: Creating Dynamic Tables West Virginia
- JSP: Creating Dynamic Tables Wisconsin
- JSP: Creating Dynamic Tables Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML