| Author |
How to do group by in a jsp
|
Omar Ali
Greenhorn
Joined: Dec 23, 2008
Posts: 13
|
|
Hello All,
I am having difficulties while doing the grouping in a jsp.
I am having a table which is retrieving the employee No., Directorate. The directorate name is coming duplicate as it is retrieved from the DB.
My jsp is displaying:
111 IT
222 IT
333 IT
So, I want it in the jsp as:
IT
111
222
333
Can you please help.
|
 |
Devaka Cooray
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2692
|
|
|
This is not something you should do right in the JSP. You can make a list of employees for each directorate from somewhere in your business classes, and make your controller to set a request attribute carrying the list of directorates. Here, each directorate object should either contain or mapped to a list of corresponding employee objects. From the JSP, you can iterate over this directorates list using forEach tag of the JSTL core library. At each iteration, you can have another (nested) forEach iteration to iterate over the corresponding employee objects.
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56200
|
|
Move any Java code out of the JSP. Putting JSP code in modern JSP is a poor practice and downright irresponsible at this stage.
I've moved this to the JDBC forum because it's not about JSP.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: How to do group by in a jsp
|
|
|