sorting by clicking a link

Hi Experts,
I have a jsp page(the view) as shown below. It displays beans that are coming from a servlet.
I would like have the header of my table used to display the bean as link so that when clicked, it sorts the beans by that field. I know how to implement the method that sorts a list of bean(as shown below ).

My question: How can i setup that link so that when clicked the jsp view is reloaded and the tabel is sorted by the field clicked?
 
==================== Sorter implementation =============
class CountryComparator implements Comparator { public int compare(Object
        obj1, Object obj2) { IpInfoBean bean1 = (IpInfoBean) obj1; IpInfoBean
        bean2 = (IpInfoBean) obj2; return ( bean1.getCountry().trim()
        ).compareToIgnoreCase( bean2.getCountry().trim() ); }
         }

and called as: Collections.sort( listOfBean, new CountryComparator() );
================= the jsp view ===================
<jsp:useBean id="listOfipInfo" type="java.util.ArrayList<IpInfoBean>" scope="request"/>
 
<center>
<b>Total # of IP: <%= request.getAttribute("numOfCountry")%></b><br>
<table border="1">
<tr>
      <th>IP</th>
      <th>Country</th>
      <th># of Country/IP</th>
</tr>
<% for(IpInfoBean b : listOfipInfo ) { %>
<tr>
      <td><%= b.getIps() %></td>
      <td><%= b.getCountry() %></td>
      <td><%= b.getCountryCount() %></td>
komlaaaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
for the header column u wish to have the sorting on the server side, have a link on each header column which points to the loading of the page (the way u come to this page initially) and add a parameter like http://localhost:8080/myapp/yourpage.do?sorting=country&orderby=desc

u need to check on the action class or servlet for the sorting parameter and do the server side handling of comparater with the list. You may add the orderby as per your needs(sure u have to handle it !)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WelkinMazeCommented:
Hi,
You can use history.go(0) to reload the page.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.