开发者

DisplayTag questions about HttpSession

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开发者_如何学Go


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜