Collections.sort(AddressArray,
Class.forName(request.getParameter("orderBy")));
This is a potential security hazard, web surfers can load any classes by
altering the parameter name.
If your columns are not dynamic, you might as well just type out the whole
conditions thing.
String orderBy = request.getParameter("orderBy");
orderBy = orderBy == null ? "someDefault" : orderBy.trim(); // Trim, and
NPE prevention
if (orderBy.equals("col1")){
// do sort
} else
if (orderBy.equals("col2")){
// do sort
}
// and so on.