Solved

Multipage Layout Data

Posted on 2002-05-03
12
198 Views
Last Modified: 2010-04-01
Hi, this is the sample coding and I hope anyone can teach me how to do multipages listing if my data is very big but I don't want to show them all in one pages. I want it to be multi pages. Thank you.

<%@ page language="java"
    import="java.sql.*, java.io.*, java.util.*, com.wrox.cars.*"
%>

<jsp:useBean id="book" class="com.wrox.cars.Books" />

<html>
  <head>
      <title> Testing For Data Access </title>
  </head>

<body>
  <h1> List Of Data From PFLIB/JAPF10  </h1>

<table border ="1">

        <tr>
           <td><b>Customer Name </b></td>
        </tr>

        <%
           book.connect();
           ResultSet rs = book.viewBooks();
           while (rs.next()) {
        %>

        <tr>
           <td><%= rs.getString("TA1021") %></td>
        </tr>

        <%
         }
        %>
</table>
<% book.disconnect(); %>
</body>
</html>


I am using JavaBeans to do the connection and sql query. Please teach how to do multipages.

TQ
0
Comment
Question by:foongkim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6988743
Ok.. I can give you simple pseudocode.

Ideally you want to use a taglib like struts or some other one to do this.. but you can try this until then:

<%@ page language="java"
   import="java.sql.*, java.io.*, java.util.*, com.wrox.cars.*"
%>
<% int maxDisplay = 50;
   String sr = request.getParameter("sr");
   int startRow = 0;
   try {
     if (startRow != null)
      startRow = Integer.parseInt(sr);
   } catch (NumberFormatException nfe) {
       startRow = 0;
     }

<jsp:useBean id="book" class="com.wrox.cars.Books" />

<html>
 <head>
     <title> Testing For Data Access </title>
 </head>

<body>
 <h1> List Of Data From PFLIB/JAPF10  </h1>

<table border ="1">

       <tr>
          <td><b>Customer Name </b></td>
       </tr>

       <%
          book.connect();
          ResultSet rs = book.viewBooks();
          int numDisplayed = 0;
          int currentCount = 0;
          while (rs.next() && numDisplayed < maxDisplay) {
            if (currentCount < (startRow + maxDisplay)) {
            numDisplayed++;
       %>

       <tr>
          <td><%= rs.getString("TA1021") %></td>
       </tr>

       <%
           }
           currentCount++;
        }
       %>
</table>
<% book.disconnect(); %>
</body>
</html>
0
 

Author Comment

by:foongkim
ID: 6993534
Yes, since you touch about the taglib, I am in the middle of finding answer of this vocab called "Taglib".

How can I use these easiest way to do my coding. If I am  not mistaken, I need to specified the URL of these taglib. Is it I have to create this taglib by my own or how?

Can share?
0
 

Author Comment

by:foongkim
ID: 6993568
cheekyci, I have tried the psedocode, it's will displayed how many "maxDisplay" I specified inside the program but it's doesn't hold my data for the next pages.

I have definitely more than 50 lines data here, but can I initiated my system to hold my others data to be stored innext pages???
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:cheekycj
ID: 6994145
You can get taglibs from various sites.

the best one is:
http://jakarta.apache.org/taglibs/index.html

Struts is easy to use and would be your best bet.

CJ
0
 

Author Comment

by:foongkim
ID: 6995429
Thank you very much......
0
 

Author Comment

by:foongkim
ID: 6995431
But I am using JSP 1.0. Did it support tag Library?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6997755
I believe JSP 1.1 is when Taglib support was started.

CJ
0
 

Author Comment

by:foongkim
ID: 6997767
Any strong documentation support you or did u tried before using JSP 1.0?

By the way, I just read some documentation regarding my multipages layout, anything to do with my database if I want to view my data in multiple pages? Or the code itself should add-in more code?

 
0
 

Accepted Solution

by:
sushifish earned 50 total points
ID: 7000537
try this:

<%
int start_num=request.getParameter("no");

if(start_num==null){
start=0;
}

int end_num=start_num+50;
Vector viewBook=jspbean_id.function_name(parameter);
%>
<html>
<body>
<table border ="1">

      <tr>
         <td><b>Customer Name </b></td>
      </tr>
<%if(viewBook.size()!=0){
for (int i=start_num;i<end_num;i++){
       String var1=(String)viewBook.elementAt(i);%>
      <tr>
         <td><%=var1%></td>
      </tr>
<%}}%>
</body>
</html>


p/s: The sample code above will able to help you to solve the problem.
0
 

Author Comment

by:foongkim
ID: 7082818
Sorry guys.... for disapear almost a month.

the code that suchfish recomended is working. But I was wonering how abouht the next 50 records, 51, 52.... will be display??

0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7092919
I am not sure.. suchfish any comments?

can you post your completed code.. so we can examine it?

CJ
0
 

Author Comment

by:foongkim
ID: 7094332
That's the only code I have.....

Totaly no idea.... I was wondering either the admin of the pages can share his/her code with us or not..

Ha....
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
spring AOP 6 91
Set up Wildfly 10 8 443
dynamic reloading of jsp in jetty 2 121
JSONSerializer.toJSON in JSP generating error 8 88
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question