1

hey guys i have a situation in which i am getting a array string of selected building names and another array string of selected building subsystems. So based on the user selection i have to generate a report in which for each building a different table has to be created over jsp page.

So the table should be like one building name in first column and the chosen subsystem in second column rows. Other columns have heading 2011, 2012 upto 2016.Hence there can be multiple table but with same set of subsystems at a time. The values in other blocks comes in based on some calculation. Its kind of forecast report in which if for eg. roofing for some building has renewal cost in 2011 then its value should come at right place.

And finally i have to get the total at the bottom of each table and further a table in which must be having grand total for each column.

here is the sample table for better understanding:-

enter image description here So can anyone suggest me what approach i should take. I can generate the table by using two for loops one for buildings and other for subsystem inside buildings

like

 for(int i ; int<building.lenth; i++){
       for(int k ; i<subsystem.lenth; i++){
      //over here i subdivide the loop into various if and else if's based on the chosen subsystem and access database everytime for each subsystem 
and get their respective values for calculations over jsp directly. In that case i'm not able to total all the columns.
    And in all its a bad practice to access database like that from jsp and doing java over jsp.
    }
    }

So the question is how should i handle this situation. What data structures can help me achieve this goal. Thanks in advance. :)

1
  • Hm, I'm not sure if I understand the problem. You have to define the data structures (objects) required to implement the use case. I think this question is still too generic... Commented Aug 10, 2011 at 17:13

1 Answer 1

3

There are existing JSP taglibs to create tables on the fly based on your data. A good example is DisplayTag. You will probably find an example on the DisplayTag site of what you want to do, and will end up having more concise JSP code.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, DisplayTag is nice option but is there any sample source code which may help me to understand the proper throwing of data and catching values in displaytag. I checked the link given by you but still i'm not much clear on how to use them
If you're loking for DisplayTag's source code, its available @ sourceforge.net/projects/displaytag/files/… . If you're looking for examples of how to use DisplayTag, it has multiple examples on the site, under the "Tutorials" section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.