Link to home
Start Free TrialLog in
Avatar of aauser
aauser

asked on

servlet dynamically add/drop a column from table

Hi,
  I can add or drop a column in my table,
but how can I make it so that it dynamically
update on how to display the total column
from the table:

ex: Let says currently have a table with three columns;
if I add one more column, how can I write a loop
so that it prints out four columns; and if I delete
one column, how can I write a loop so that i prints
out 2 columns with headings ,headings can be the name of the colums, (when I select to query database).


String col1 = "Name";
String col2 = "phone";
String col3 = "email";

out.println("<TD>"+col1+"<TD>"+col2+"<TD>"+col3");
while (rset.next ()) {
             out.println("<TR>");
             for (int i=1;i<=3;i++) {
                out.println("<TD>"+rset.getString
                 (i));
             }


====
html file:
Column Name:<INPUT type=text name="newcolumn">



thanks in advance:


ASKER CERTIFIED SOLUTION
Avatar of avalys
avalys

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
You need to maintain a list of required columns in the session, and use this list when constructing query and resulting table.