Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Meenachi Suppiah   on Jul 04 In Java Category.

  
Question Answered By: Taylor White   on Jul 04

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.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Collections.sort Question Or get search suggestion and latest updates.


Tagged: