• Post Reply 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

display search results as sets of pages

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using a servlet that calls a bean which does a backend query and gets some Values as Elements. I am not using JDBC connections but using JCO connections to connect to SAP and get the required table Values. I have stored the table values into an Arraylist as follows in my Servlet

ComputeSearchBean Search=new ComputeSearchBean();
ArrayList beans = new ArrayList();
for(int i=0; i<Project_Prps.getNumRows(); i++){
Project_Prps.setRow(i);
int j=0;
Search.setWBSXYZ(Project_Prps.getString("XYZ"));
j=j+1;
Search.setWBSABC(Project_Prps.getString("ABC"));
beans.add(Search);
}

Then a call the required JSP file in which i should use the table values as

req.getSession(true).setAttribute("Search1", beans);
String url = "/Search.jsp"; //relative url for display jsp page
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, resp);

My question is how to implement the JSP which will have the results diplayed as 50 elements per page. User can then use the next or previous to scroll across the webpage to see more results. How should i take care of the session so that through out the session user will see the results for his queries.
And i am talking about search results that could be 0 results or 500 results. dynamically how should i write the jsp page so that it displays them in a table in the center of the page.

Thanks and any help will be greatly appreciated.
John
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

U can handel that dynamic display with the help of java script like displaying data in the table upto 50 rows . i think u go tmy point . :roll:
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a classic question that comes up often. Think about some of these choices:

Execute the query, return the first 50. To display any other page execute the query, skip page*50 rows and return the next 50.

Execute the qeury, store all the results on the session. To display any page get rows starting at page*50.

Execute the query, store all the primary keys on the session. To display any page get the keys starting at page*50 and retrieve the full row data.

Execute the query and hold a cursor open. To display any page read the cursor forward or backward.

Execute the query and return the first 50. To scroll forward execute the query with key > highest key in the first 50. Maybe store the first key on each page in the session so you can scroll backward.

And Venkat's idea - retrieve all the rows clear out to the browser, maybe an XML island or hidden fields or something. Page through them with JavaScript without going to the server again.

More ... any ideas?

Lots of choices. Do any of them sound like they'd work for you?
[ July 02, 2004: Message edited by: Stan James ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic