Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple sessions paging result sets...

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Greetings Big Moose Saloon.
I am interested in using a tabular result set display binding tag library like either DisplayTag (Sourceforge) or DataGrid (Apache), and paging results (from a database). I can do all of this fine, but the question I have is a question of result collection object scoping, and multiple sessions.
The problem/challenge that I have is that if I put the List/Collection object for the results in session scope, and the user opens another session, then the new session object clobbers the last sessions session scoped object.
I'm kind of looking for a general purpose technique (if it exists) to page result sets in potentially more than one session. Another criteria I have is that I do not want to requery when the users page through results (I will be doing a "top-500" query, retrieving the first 500 records and then allowing for the users to page through those, sort them, export them, etc).
I was thinking I might avoid this object collision/clobbering problem by maybe creating a separate session object for each result set (or having separate session result sets be elements in an Array) and supplying the particular session's array-index as a request parameter to the view page or something like that. This seems like it would work, but have the downside of causing problems with session cleanup... Like how would I know which objects are active (since the result sets are largish, then I would expect performance degradation if I just ignore cleanup).
Thank you very kindly for reading, and I am greatful for any and all comments or suggestions.
Sincerely,
-Jim
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi, welcome to the ranch!

We've had lots of conversations about pagination, but I don't think with the multi-session concerns you've raised. How does a user come to have multiple sesions?
 
Jim Hardin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'm sorry--my apologies. I did *not* mean to say that the user has multiple "sessions", but that the user has multiple "brower windows" open. That really undermined my whole question. Excellent clarification, thank you. Please substitute "browsers" where I said "sessions"... Thank you very much.
-Jim
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If you open IE (or I imagine most or all other browsers) twice by starting it from some shortcut you'll get two sessions. They are independent and act like two users at two computers in most respects.

If you use File/Open/New Window or use JavaScript or target to pop a new window you'll get a new window on the same session. Then you could be browsing the same dataset in two windows at two different locations. Is that the situation?

Could each window keep track of its own position and ask for the next or prior screen full of data by row number or page number?

Some pagination options ...

Repeat the whole query every time, which you already ruled out.

Repeat a partial query every time with starting row number or starting key and a number of rows. I don't think there is a standard, portable way to do this on all databases. Might not be able to page backwards.

Query once, save all the results in memory, page the user up and down the memory collection. Takes lots of memory!

Query once, save all the keys in memory, page as before, query a page full of data using the keys. Less memory, more database queries.

Query once, save all the results somewhere not in memory ... on disk, another database table, in the transporter buffer ...

Any of those sound interesting?
 
Jim Hardin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Stan,
I reformulated my question thanks to your helpful clarification. Please see below for a *hopefully* clearer articulation of my question.
I am thinking that maybe a better forum for this question might be a more webapp oriented one, like say the JSP forum, and I might post it tomorrow on that--I will reply back on this if I end up doing that. Please feel free to give this a read. Thank you for all the help.
-Jim

I am interested in using a tabular result set display binding tag library like either DisplayTag (Sourceforge) or DataGrid (Apache), and paging results (from a database). I can do all of this without any problems; the question I have is a question of result collection object scoping, and potentially multiple browsers open for a user session.

The problem/challenge that I have is that if I put the List/Collection object for the search result in session scope, and the user opens another browser (via ctrl-N, whatever), then any subsequent interrogation done in the new browser window will clobber the session scoped result object which was originally created by the first browser interaction.

Note: I'm assuming there is no clear way to page through a request scoped collection, because the request lifecycle has ended when the first page is rendered on the browser.

Also, to clarify, the session scoped collection is the first up-to-500 rows of some ad-hoc database search/interrogation; on the search form, the user specifies some mandatory and optional search criteria, and a dynamic query is executed populating the (currently session) scoped collection with results. I *do not* want to requery the database (not even partial result set queries for page subsets) as the user pages paging through these potentially up-to-500 results (this is not an option, sorry).

At this juncture some EJB adepts might suggest "stateful session EJBs" are the solution, but I would personally prefer to avoid EJB altogether if possible. Maybe that's really the most natural approach though? Anyway, if after searching/retrieving some initial results, but before paging to say the 2nd page, suppose the user opens another browser window and goes back and performs a different ad hoc search/interrogation, repopulating the same session scoped collection which the first browser window is supposed to be paging through, clobbering the previous results. My dilemma is what's the best way to handle this problem.

What I'm hopefully kind of looking for a is general purpose technique/approach/standard-practice (hopefully strictly webapp, no EJB, if possible) which might allow users to page results concurrently in multiple browser windows.
Thank you very much.
-Jim
 
Jim Hardin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Stan,
I reposted this reformulated question on the JSP forum. Thank you very much for all of the help!
-Jim
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yup, that was a good move there. Sounds like session scope needs some qualification, maybe a map keyed by some unique identifier from each browser window.
 
    Bookmark Topic Watch Topic
  • New Topic