This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I have remote data in the form of parent child records. My idea is to get this data into a class as array objects. Then present this to the user in a table where the parent data is in the left cell of a table with the child records in the right cells. Then I need to the parent cell to be dynamic in nature so that part of the table could expand and colapse. Is this doable? So far I have the class creating two arrays. One array in a one dimensional array holding the parent records. The second array is a three dimensional array holding the parent, child field1, child field2. I am stuck on haow to get this into my servlet and thn to be presentd on my JSP. I do arrays of arrays all the time with two dimensional arrays but this seems tricky.
To start with, I would try first to create the HTML for the page with a servlet, rather than a JSP page. I'm not sure if you could present such a complex, homegrown data structure with a commercial JSP tag library, or if it is even worth it to develop your own set of JSP tags.
Writing the HTML directly from the servlet code seems like a good way to start. [ September 30, 2008: Message edited by: James Clark ]
I advice you to write a taglib yourself to build the data presentation. Thus, the servlet build the Arrays, the presentation logic will be placed into the Taglib and your JSP will stay "clear". If you need any changes in the future, you go directly to the taglib.
I agree with the statements about having Java code write the HTML from a servlet.
The key part of my sentence was "...seems like a good way to start." There is no need to find the perfect solution on the first try or to get bogged down with all the details, but get nothing accomplished.
The OP seems a bit lost with "how" he can get his data structure to display in an HTML table. The first thing to verify is that this array-based data structure can be manipulated to populate one or more HTML tables. If he can do it in a servlet, he could then move the code into a custom JSP tag at a later point in time. This is the better solution.
There could be other good ways to start, as indicated, e.g. via JSTL tags. [ September 30, 2008: Message edited by: James Clark ]