luca invernizzi wrote:Hello,
I have to get a field from a database in a dynamically way.
The table in the database have same field like:
ic1, sc1, tc1, ic2, sc2, tc2 ....... and so on until...... ic30, sc30, tc30
What a mess. And sending a mess like that to a JSP is a guaranteed way to make sure that there JSP is convoluted and fragile.
Rather, take care of the mess in the controller, and then pass well-behaved constructs to the JSP where they are easy to deal with.
In this case I would take the ic1, ic2,...ic30 values on pit them in a List implementation. Same of the sc and tc values.
Now you have well-behaved lists that are easily addressed by index.
So all the complexity stays out of the JSP code (where it doesn't belong) and stays in
Java code (controller) where it should be.
Though personally I would find the person that decided upon that scheme in the first place, brick him into a closet with a cask of Amontillado, and find someone who could do a more resemble job.