In web development, you may be able to use a pre-written component depending on your framework. For example,
JSF (Java Server Faces) is likely to have such widgets.
From the JDBC end, take a look at Cached Result Sets for holding data from a query while disconnected from the database.