Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes transpose ResultSet for JSP display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "transpose ResultSet for JSP display" Watch "transpose ResultSet for JSP display" New topic
Author

transpose ResultSet for JSP display

Riley Brook
Greenhorn

Joined: Oct 24, 2002
Posts: 5
I have a ResultSet object derived from a 1:N join

In my display/report/JSP (really
Riley Brook
Greenhorn

Joined: Oct 24, 2002
Posts: 5
I have a ResultSet object derived from a 1:N join


In my JSP I would like to display that as ONE line item:

What's the best way to go about doing this?
Approach (?) Create a business object (OrderNum) and do the relational mapping in the bean code. Have the JSP use the bean.
Cons: This seems wasteful to create java objects for this pupose. There will be many OrderNums and they are shortlived objects.
Any other ideas? This is a repeatable problem throghout my app and I would like to apply this approach globally.
Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Hi Riley...
u can create a Java DVO (Data Value Object or business object as u say....) to hold this results and send the result on to the jsp .
Anyway to communicate between the jsp and the class from where u r making the database call will be much more simpler and user defined if u use dvo's .
The DVO can have request scope by setting it in the request hence the scope of them also will be controlled and they will be eligible for gc as soon as the request from the jsp is completed.
another approach is using the result set itself which is absolutely not recomemded in the jsp....!!!
u'r idea of a business object is good enuf and will provide u with the control for the messaging protocol between the jsp and the class which is doin the database calls.
Riley Brook
Greenhorn

Joined: Oct 24, 2002
Posts: 5
devesh -- thanks for the reply
I agree I wouldn't want to actually use the resultset in the jsp and putting whatever DVO in the request scope will allow "messaging" between the tiers.
I guess my concern was around overhead of creating composite objects that will be so shortlived, then having the GC destroy them afterwards.
We have a data object (think disconnected resultset) which has all the mutators of a resultset but has already disconnected from the db. Its really a vector of vectors. Usually the row vector corresponds to a row in the display so its easy to loop through. In this case (one to many) the idea breaks down.
I'm concerned about now creating a DVO object(order) from my object described above which will have a hash of other objects (items) which might have hash of other objects (tbd) per request. Many users, many requests this can add up (?)
Seems memory heavy and wasteful? No? Should I not be concerned about this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transpose ResultSet for JSP display