Announcement Announcement Module
No announcement yet.
Minimizing session data ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Minimizing session data ?

    I was wondering what others are doing to avoid the build up of large amounts of session data. For example , I have search page that returns lists and I keep the list in my session so can page through the data. When the the person leaves the page and goes to another search page this list is still in my session . Other than keeping everything in request scope , is there some way that I can remove the session data when a user leaves the search page ? I know that I can remove the attribute from the session but just wondering if there is some sort of strategy as to know when to take it out of the session since the user can navigate almost anywhere after performing a search. I am doing something similar to JPetstore example with PageListHolder .. but there are alot of search pages and the results are rather large and seem to accumulate.

  • #2
    You could implement a HandlerInterceptor cleaning out the session on every request. The HandlerInterceptor gives you info about what handler is going to be executed so you could in theory clean out everything except for the data needed by the controller that is going to be executed.

    It's a tricky approach however, since if the user navigates back to the controller that needs the session-scoped data, you're f*cked.

    I'd rather keep everything in request scope and implement my paging some other way (only retrieve the page the user wants).



    • #3
      Use WFNM

      Check out WFNM. The idea behind it is to associate related pages into "WebFlows". When exiting a webflow, all of the session objects created in it are reclaimed.

      (Shameless Plug)
      If you are using Eclipse, you may want to check out the upcoming 0.9.2 release of Gaijin Studio for Spring MVC. You can create process flows visually and the plugin generates the dispatchers, bean config files, controller prototypes, web descriptor, etc.. it also automatically adds the WFNM filter/interceptor so that there is no code required for reclaiming session objects.
      (End Shameless Plug)

      Hope that helps!
      Derek Adams
      dadams (at)