Presently working on a search and listing page. The search may retrieve an ArrayList of data but on the list page, oni a limited 10 lists of data will be shown. Does anyone noe how do i keep the rest of the data so that when user click "next" list of data, i can display the next few data in the listing page? have used set and get attribute to display the 1st set of results but when i use get attribute again... it return null.
thks in advance...
-
How to retrieve and store data in a web application (2 messages)
- Posted by: ss d
- Posted on: January 09 2006 08:49 EST
Threaded Messages (2)
- How to retrieve and store data in a web application by Eugene Choi on January 09 2006 10:12 EST
- How to retrieve and store data in a web application by Krishna Pothula on January 14 2006 04:42 EST
-
How to retrieve and store data in a web application[ Go to top ]
- Posted by: Eugene Choi
- Posted on: January 09 2006 10:12 EST
- in response to ss d
if you are using just jsp/servlets, you will need to put the arrayList into HttpSession object.
if you are using JSF, you can use managed-beans with session scope.
or if using some sort of ORM will be similar as well.
or if going stateless, and if the list is small,
you can stringfy (either the data, or html representation) the data in a hidden input field so that you can pass it from one page to another.
or a ghetto way is to keep track of the page you are on
in a hidden input field, and every time they switch a page, take a hit on the db w/ a sql query that needs the page to be passed in. -
How to retrieve and store data in a web application[ Go to top ]
- Posted by: Krishna Pothula
- Posted on: January 14 2006 04:42 EST
- in response to ss d
The ArrayList data that you store in request is stored only for the request Scope. To use the same Object on multiple pages you should store the Object in session.
Storing:
request.getSession().setAttribute("mylist", listObj);
Retrieving:
request.getSession().getAttribute("myList");
This object stays as along the session is valid. If this Object is very large then you should consider clearing this object after use.
Clearing:
request.getSession().removeAttribute("myList");