tags:

views:

172

answers:

1

Hi,

I just started using the displayTag to store my entire resultset of objects from a database query and display them in a paginized format within a JSP.

I found that I had to store the entire resultset in the HttpSession, otherwise the displayTag looses the data which advancing to the next page.

My question/concern is storing this large object graph in the session. Should I manually clean up the session after the user leaves the JSP which uses the displayTag? Or perhaps I am missing something. It would be nice if I could store my resultset in the request and have the displayTag manage the memory of these objects.

Thank you

A: 

The display tag just uses values from the page context, which can be any of page, request, session, or application scope. When I've done things like what you describe I've used request scope, which avoids the problem you're describing - if you want to cache objects in the user session, there's nothing other than the timeout to control how long they stick around. Caching in the session isn't so great because a user may simply stare at that page for 10 minutes, while that result set just sits on your server taking up space.

If you really must cache, it might be better to cache globally, if you can find a way to make your data shareable between users in some way. Another option might be to only pull the data you need for specific requests - for example, paginating not by loading an entire set of rows and displaying a subset, but by only loading the individual subsets.

Steve B.
Thanks, I originally put the results in the Request, but when I started advancing pages, the results were gone. Only page 1 displayed correctly. I will use the Session but will try to return a subset of data from the database.
Sam K