Say you have a table with firstname and lastname columns. And you have your jsp,
viewNames.jsp.
The way I did it was create your query.
String stmt = ("SELECT fname, lname FROM table_names ORDER BY " + what);
Then in your servlet or jsp set your what:
String what = request.getParameter("what");
Then your column headings would be your links, and you would put the what in there.
So your html would be like:
<table border=0 width=100%>
<tr>
<td>
<a href="viewnames.jsp?what=firstname">First Name </a>
</td>
<td>
<a href="viewnames.jsp?what=lastname">Last Name </a>
</td>
</tr>
<tr>
<td>
<%= rs.getString(1) %>
</td>
<td>
<%= rs.getString(2) %>
</td>
</tr>
</table>
HTH.
At 02:00 PM 5/3/2001 -0500, you wrote:
>Has anyone had any experience using a servlet to sort table columns? I'm
>filling a table dynamically and I want to sort the results by columns with
>the column headers being links that will sort the data in that particular
>column.
>
>I would appreciate any feedback on this.
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets