JSP performance issue

I am currently having a query which fetches 12000 records from a database and it is a simple select query.
Iam storing this in a result set as we normally do and looping throgh it and displaying all 12000 records in a single page.The problem is it takes more than 15 minutes to load this page which shows all records.Can anysone please suggest if there is a way to speed up the response time.
One more thing...
I am displaying the results using out.println statement
something like this for eg..(out.print("<table width='900' align='absleft' border='1' cellspacing ='1' cellpadding ='1'>");)
The entire HTML tags are generated using out.println with in JSP..Is this a reason why this might be happening ?
kalyanmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

somasekharCommented:
Hi

This can be resolved in 2 ways


1. Application level caching

you  can solve this problem by using value list handler pattern which is available at
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html


2.Database level Caching

 you can use JDBC2.0 compain driver which is having cached rowset.
http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html 

Hope this will help you
Regards
SomaSekhar
0
kalyanmAuthor Commented:
I agree with your answer totally but I am looking for code to be embedded with in a JSP using normal result set .can't this be done
0
TimYatesCommented:
Don't show all the records...

Just show say 100 of them, and have a "next 1000" button...

In postgres, you can fire SQL like:

SELECT * FROM TABLE OFFSET 1000 LIMIT 1000 ;

Which will show you 1000 records starting at record 1000...

Just have the next 1000 button redirect to the same page with a higher offset for the query...

Tim
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

TimYatesCommented:
> Just show say 100 of them

should read:

Just show say 1000 of them


It should be said that 12000 items in one go is way too many...  No-one can process that amount of info...

Sure, have a download, where you send a CSV file containing the data if the idea is to load it into Excel or something, but don't show 12000 records at once on the same page...

At least, that's my thoughts...
0
kalyanmAuthor Commented:
Thanks Tim I ahd proposed this solution that is using 'next' and 'prev' links and scrolling thorugh but the requirement is such that I ahve display this in a single page.Also do you have any code which fetches set of results at a time and scrolls using next and prev as you have proposed in your solution.Can you please pass this code
0
kalyanmAuthor Commented:
Yes TIm I have a excel download option as you suggested can you please provide me with 'next' and 'prev' code as Iam new to JSp and had tried using tag lib but no result
0
TimYatesCommented:
*something* like this:

This SQL is how Postgres does it...  so you'll need to change it to suit your db...

Tim


<%
    String sOffset = request.getParameter( "offset" ) ;
    if( sOffset == null )
        sOffset = "0" ;
    int offset = Integer.parseInt( sOffset ) ;

    // call the sql function filling in the offset value with this one:
    // this should be replaced with your db code, where the SQL is something like
    //  SELECT * FROM table ORDER BY id OFFSET offset LIMIT 1000 ;
    List results = DBBean.getList( offset ) ;
 
    // then show the results:
    for( int i = 0 ; i < results.size() ; i++ )
    {
%>
    <%= offset + i %>: Value = <%= results.get( i ) %>
<%
    }
   
    // then put in the next and prev links:
    int prev = offset - 1000 ;
    if( prev < 0 ) prev = 0 ;
    int next = offset + 1000 ;
%>

    <a href="<%= "?offset=" + prev %>">&laquo; Prev</a>
    <a href="<%= "?offset=" + next %>">Next &raquo;</a>
0
kalyanmAuthor Commented:
Tim I have my database code something like this can you suggest the above scenario for this

              String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
             String url = "jdbc:odbc:Momqts";
      Class.forName(myDriver);
                Connection conn = DriverManager.getConnection(url);
                Statement stmt = conn.createStatement();
      rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members);//this fetches 12000 records//

                if(rslt!=null)
            {
               
                  while(rslt.next())
                  {
                         String mqrid =rslt.getString("Emp_no");
                         String mdate=rslt.getString("project_id");
                         String mid=rslt.getString("Emp_name");

Thanks in advance
0
TimYatesCommented:
Ok, something like this:

(assuming you are using MS SQL server... what db are you using?)

Note; limiting the returned results from SQL Server or access is a PAIN IN THE A$$ -- that's why the SQL is kinda horrible :-(

Tim...

<table>
<%
    String sOffset = request.getParameter( "offset" ) ;
    if( sOffset == null )
        sOffset = "0" ;
    int offset = Integer.parseInt( sOffset ) ;

    String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:Momqts";
    Connection conn = null ;
    Statement stmt = null ;
    ResultSet rslt = null ;
    String sql = "SELECT Emp_no, project_id, Emp_name FROM members ZZ " +
                       "WHERE ( SELECT COUNT(*)  FROM members WHERE Emp_no < ZZ.Emp_no ) " +
                       "BETWEEN " + offset + " AND " + ( offset + 1000 ) + " " +
                       "ORDER BY Emp_no ASCENDING" ;
    try
    {
        Class.forName( myDriver );
        conn = DriverManager.getConnection(url);
        stmt = conn.createStatement() ;
        rslt = stmt.executeQuery( sql ) ;

        while(rslt.next())
        {
            String mqrid =rslt.getString("Emp_no");
            String mdate=rslt.getString("project_id");
            String mid=rslt.getString("Emp_name");
%>
    <tr><td><%= mqrid %></td><td><%= mdate %></td><td>mid</td></tr>
<%
        }
    }
    catch( ClassNotFoundException ex )
    {
        out.println( ex.getMessage() ) ;
    }
    catch( SQLException ex )
    {
        out.println( ex.getMessage() ) ;
    }  
    finally
    {
        try { if( rslt != null ) rslt.close() ; } catch( SQLException ignored ) {}
        try { if( stmt != null ) stmt.close() ; } catch( SQLException ignored ) {}
        try { if( conn != null ) conn.close() ; } catch( SQLException ignored ) {}
    }
    // then put in the next and prev links:
    int prev = offset - 1000 ;
    if( prev < 0 ) prev = 0 ;
    int next = offset + 1000 ;
%>

    <a href="<%= "?offset=" + prev %>">&laquo; Prev</a>
    <a href="<%= "?offset=" + next %>">Next &raquo;</a>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimYatesCommented:
I *really* hope that SQL works...I have no way of testing it...
0
TimYatesCommented:
Damn...forgot

</table>

before the <a href at the bottom ;-)
0
kalyanmAuthor Commented:
Thanks and lot ...
Iam using oracle db ..does anything from above change if I use oracle or msaccess db
0
TimYatesCommented:
Why are you using the jdbc/odbc bridge for oracle?

I would have thought the oracle thin drivers would have been better?

Hehe, yeah for oracle, the SQL turns into:

    String sql = "SELECT * FROM ( " +
                           " SELECT ROW_NUMBER() OVER( ORDER BY Emp_no ) LINENUM, Emp_no, project_id, Emp_name " +
                           " FROM members " +
                           " ORDER BY Emp_no " +
                       ") WHERE LINENUM BETWEEN " + offset + " AND " + ( offset + 1000 ) ;
 
(I think)

again, I have no way of testing this :-)

Tim
0
kalyanmAuthor Commented:
Tim
The above query was for ms access db and not for oracle I'm using thin driver for oracle..
Thanks for your suggestions.
0
TimYatesCommented:
Did it speed things up?

Hope so!

Good luck with it all :-)

Tim
0
TimYatesCommented:
Only a grade B?  *sniff*
0
kalyanmAuthor Commented:
Oops didn't relaise that ..but can't modify the grade now...
0
TimYatesCommented:
Hehe, never mind ;-)

*shakes fist*

;-)  *giggle*

Good luck again :-)
0
kalyanmAuthor Commented:
Tim...This works thanks can I use the same query for oracle as you have given above instead of the other one you have given below

String sql = "SELECT Emp_no, project_id, Emp_name FROM members ZZ " +
                       "WHERE ( SELECT COUNT(*)  FROM members WHERE Emp_no < ZZ.Emp_no ) " +
                       "BETWEEN " + offset + " AND " + ( offset + 1000 ) + " " +
                       "ORDER BY Emp_no ASCENDING" ;
0
TimYatesCommented:
That one's for oracle, the first one I gave is for SQL Server or Access :-)

They have different ways of doing the same thing :-/

PostgreSQL for example just needs:

String sql = "SELECT Emp_no, project_id, Emp_name FROM members OFFSET " + offset + " LIMIT " + ( offset + 1000 ) ;

Tim
0
kalyanmAuthor Commented:
Tim
With the method you have suggested, things have defintely improved when I tried this with access db but
 the requirement is such that I cannot put prev or next in my page which displays results which means i ahve display the entire set in one go.Any ideas about how I can speed things up.
0
TimYatesCommented:
you will have to cache them then...

Rendeing 12000 items will take a long time for the browser to do anyway, so you're going to get a big delay no matter what you do...
0
kalyanmAuthor Commented:
Thanks Tim Can you please provide me with any sample code for caching for the code which I have given before.
0
TimYatesCommented:
Are you sure you cannot show the lines in pages?  This really isn't a good idea :-(

You will have to take into consideration:

a)  When the table updates, you need a way of updating the cache
b)  The cache will use up a considerable chunk of memory which you will never get back
c)  12000 lines will take a long time to render on the client's browser
d)  12000 lines is probably too much information to show to a user at one time

basically, what you will need to do, is write a java class which holds a row (ie has getEmpNo(), setEmpNo(), etc methods), then;

1)  Check to see if getServletContext().getAttribute( "cache" ) contains any data (a java.util.List)
2)  If so, goto 7, if not goto 3
3) perform your original SQL query to load the entire table
4)  loop through the resultset, and for each row, create a row object, and set the data in it
5)  add the row object to a java.util.ArrayList
6)  when you have added all the data, do:  getServletContext().setAttribute( "cache", list )
7)  loop through this list, and create your HTML table

It's going to be a bit faster...but still not incredibly quick...

I don't see why you want to show a 12000 row table to the user still...

Another thing that might speed things up (a bit) is using a ConnectionPool...

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

as creating a new connection to the database takes a suprising amount of time...

Again, good luck...

Tim
0
kalyanmAuthor Commented:
Tim
Iam in processing of convincing the guys to follow your pattern...
I had one doubt .If I have 100 records should I change the value of offset which is currently 1000 to someother value,also by clicking on next and previous links how can i scroll through results.please advice the changes in code below
********************************************************************
<table>
<%
    String sOffset = request.getParameter( "offset" ) ;
    if( sOffset == null )
        sOffset = "0" ;
    int offset = Integer.parseInt( sOffset ) ;

    String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:Momqts";
    Connection conn = null ;
    Statement stmt = null ;
    ResultSet rslt = null ;
    String sql = "SELECT Emp_no, project_id, Emp_name FROM members ZZ " +
                       "WHERE ( SELECT COUNT(*)  FROM members WHERE Emp_no < ZZ.Emp_no ) " +
                       "BETWEEN " + offset + " AND " + ( offset + 1000 ) + " " +
                       "ORDER BY Emp_no ASCENDING" ;
    try
    {
        Class.forName( myDriver );
        conn = DriverManager.getConnection(url);
        stmt = conn.createStatement() ;
        rslt = stmt.executeQuery( sql ) ;

        while(rslt.next())
        {
            String mqrid =rslt.getString("Emp_no");
            String mdate=rslt.getString("project_id");
            String mid=rslt.getString("Emp_name");
%>
    <tr><td><%= mqrid %></td><td><%= mdate %></td><td>mid</td></tr>
<%
        }
    }
    catch( ClassNotFoundException ex )
    {
        out.println( ex.getMessage() ) ;
    }
    catch( SQLException ex )
    {
        out.println( ex.getMessage() ) ;
    }  
    finally
    {
        try { if( rslt != null ) rslt.close() ; } catch( SQLException ignored ) {}
        try { if( stmt != null ) stmt.close() ; } catch( SQLException ignored ) {}
        try { if( conn != null ) conn.close() ; } catch( SQLException ignored ) {}
    }
    // then put in the next and prev links:
    int prev = offset - 1000 ;
    if( prev < 0 ) prev = 0 ;
    int next = offset + 1000 ;
%>

    <a href="<%= "?offset=" + prev %>">&laquo; Prev</a>
    <a href="<%= "?offset=" + next %>">Next &raquo;</a>
****************************************************************
0
TimYatesCommented:
If you want to show 100 records at a time, then change all instances of "1000" to "100" :-)
0
kalyanmAuthor Commented:
Tim
Suppose I have 100 records in total and I have to show 10 recs at a time
I changed all instances of 1000 to 10 but it did not display any records till the offset reached 90

SELECT ID, SAP, CSS_DATABASE, VP_ACCOUNT, INSTALLATION_NAME, ORDER_RECEIVED, MDRA AS STATUS  FROM TBLSAP WHERE ( SELECT COUNT(*)  FROM TBLSAP WHERE (MDRA LIKE 'EBP%') AND MAI2 IS NULL ) BETWEEN " + offset + " AND " + ( offset + 20 ) + " AND (MDRA LIKE 'EBP%') AND MAI2 IS NULL ORDER BY ORDER_RECEIVED DESC

Can you help please
0
TimYatesCommented:
is this any better?

I am just guessing though...

SELECT ID, SAP, CSS_DATABASE, VP_ACCOUNT, INSTALLATION_NAME, ORDER_RECEIVED, MDRA AS STATUS  FROM TBLSAP WHERE ( (MDRA LIKE 'EBP%') AND ( MAI2 IS NULL ) ) AND ( ( SELECT COUNT(*)  FROM TBLSAP WHERE (MDRA LIKE 'EBP%') AND ( MAI2 IS NULL ) ORDER BY ORDER_RECIEVED ) BETWEEN " + offset + " AND " + ( offset + 20 ) + " ) ORDER BY ORDER_RECEIVED DESC
0
kalyanmAuthor Commented:
Tim this still doesn't help looks like the previous query was better.However my concern is in the below query:
the offset is initialised to '0' to start with and assuming that I have total of 100 records and I want to display only 10 recs per page.
*********************************************************************************
SELECT ID, SAP, CSS_DATABASE, VP_ACCOUNT, INSTALLATION_NAME, ORDER_RECEIVED, MDRA AS STATUS  FROM TBLSAP WHERE ( SELECT COUNT(*)  FROM TBLSAP WHERE (MDRA LIKE 'EBP%') AND MAI2 IS NULL ) BETWEEN " + offset + " AND " + ( offset + 10 ) + " AND (MDRA LIKE 'EBP%') AND MAI2 IS NULL ORDER BY ORDER_RECEIVED DESC
************************************************************************
from the above query offset starts with 0 and increments by 10 so if my count is 100 it will check if the count is between 0 and 10 for the first time and since this is wrong it will not display all records till the offset value is between 100 and 110
so can you please advice
0
kalyanmAuthor Commented:
Tim
Could you please give me a sample code of how my code can be used with pager tag lib as I heard that this is the best option
0
TimYatesCommented:
http://jsptags.com/tags/navigation/pager/index.jsp

comes with working examples on how to use it :-)
0
kalyanmAuthor Commented:
Tim
I have followed all the instructions and downloaded the tag lib but get errors is there any problem with code below
<%
      
      ResultSet rslt = null;
        StringBuffer make = new StringBuffer();
        ArrayList nameList = new ArrayList();
      StringBuffer sb = null;       
      
        try {                                                                    
                String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
            String url = "jdbc:odbc:Momqts";
            Class.forName(myDriver);
                Connection conn = DriverManager.getConnection(url);
                Statement stmt = conn.createStatement();
            rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members);
                int sn=0;
                if(rslt!=null)
            {
                   
                  while(rslt.next())
                  {
                         String mqrid =rslt.getString("Emp_no");
                         String mdate=rslt.getString("project_id");
                         String mid=rslt.getString("Emp_name");
                         make.append(mqrid);
                         make.append("\t");
                   make.append(mdate);
                   make.append("\t");
                     make.append(mid);
                         make.append("\n");
                         sb.append(mqrid);
                         sb.append("<TR><TD ALIGN=\"CENTER\">");
                         sb.append(mdate);
                         sb.append("</TD><TD ALIGN=\"CENTER\">");
                         sb.append(mid);
                         sb.append("</TD></TR>\n");
                         nameList.add(sb.toString());
                  
             
%>
<pg:pager items="<%= nameList.size() %>"
          index="center"
          maxPageItems="5"
          maxIndexPages="10"
          isOffset="<%= true %>"
          export="offset,currentPageNumber=pageNumber"
          scope="request">
 
    <input type="hidden" name="pager.offset" value="<%= offset %>">
    <pg:index>
           <jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
    </pg:index>
<TABLE WIDTH="80%" BORDER="1">
    <TR><TH>Name</TH><TH>Age</TH><TH>project</TH></TR>
<%
    for (int i = offset.intValue(), l = Math.min(i + maxPageItems, nameList.size());
         i < l; i++)
    {
%>
    <pg:item><%= (String)nameList.get(i) %></pg:item>

<%
    }
%>
0
TimYatesCommented:
you never close the table or pager tags...
0
kalyanmAuthor Commented:
Sorry didn't get that,I'm posting my full code can you please help
<html>

<head>
<title> New Document </title>
</head>
<%@ page language="java" import="java.*,java.sql.*,java.util.*,java.io.*" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<body bgcolor="lightblue">
<%
String columnName = request.getParameter( "column" );
if( columnName == null ) columnName = "Emp_no";
%>

<p><font size="6"><strong><font color="#ad1f92">PCNBS</font> </strong></font></p>
<script language="javascript" src="menu.js"></script>

<form name="frmadd" method="post" action="listadd.jsp">
<p>&nbsp;</p>



  <%
      
      ResultSet rslt = null;
        StringBuffer make = new StringBuffer();
        ArrayList nameList = new ArrayList();
      StringBuffer sb = null;       
      
        try {                                                                    
                String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
            String url = "jdbc:odbc:Momqts";
            Class.forName(myDriver);
                Connection conn = DriverManager.getConnection(url);
                Statement stmt = conn.createStatement();
            rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members);
                int sn=0;
                if(rslt!=null)
            {
                   
                  while(rslt.next())
                  {
                         String mqrid =rslt.getString("Emp_no");
                         String mdate=rslt.getString("project_id");
                         String mid=rslt.getString("Emp_name");
                         make.append(mqrid);
                         make.append("\t");
                   make.append(mdate);
                   make.append("\t");
                     make.append(mid);
                         make.append("\n");
                         sb.append(mqrid);
                         sb.append("<TR><TD ALIGN=\"CENTER\">");
                         sb.append(mdate);
                         sb.append("</TD><TD ALIGN=\"CENTER\">");
                         sb.append(mid);
                         sb.append("</TD></TR>\n");
                         nameList.add(sb.toString());
                  
             
%>
<pg:pager items="<%= nameList.size() %>"
          index="center"
          maxPageItems="5"
          maxIndexPages="10"
          isOffset="<%= true %>"
          export="offset,currentPageNumber=pageNumber"
          scope="request">
 
    <input type="hidden" name="pager.offset" value="<%= offset %>">
    <pg:index>
           <jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
    </pg:index>
<TABLE WIDTH="80%" BORDER="1">
    <TR><TH>Name</TH><TH>Age</TH><TH>project</TH></TR>
<%
    for (int i = offset.intValue(), l = Math.min(i + maxPageItems, nameList.size());
         i < l; i++)
    {
%>
    <pg:item><%= (String)nameList.get(i) %></pg:item>

<%
    }
%>

      
<%
                       
                       }
                         
                                                                          
            }
            rslt.close();                          
                stmt.close();                          
                conn.close();                          
            
       }

      catch(Exception e) {                      
               System.err.println(e);                
         }
      
%>
 
</table>
</form>
</body>
</html>
0
TimYatesCommented:
<html>

<head>
<title> New Document </title>
</head>
<%@ page language="java" import="java.*,java.sql.*,java.util.*,java.io.*" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<body bgcolor="lightblue">
<%
String columnName = request.getParameter( "column" );
if( columnName == null ) columnName = "Emp_no";
%>

<p><font size="6"><strong><font color="#ad1f92">PCNBS</font> </strong></font></p>
<script language="javascript" src="menu.js"></script>

<form name="frmadd" method="post" action="listadd.jsp">
<p>&nbsp;</p>
<%
     ResultSet rslt = null;
     Connection conn =  null ;
     Statement stmt = null ;
     ArrayList nameList = new ArrayList();
     StringBuffer sb = null;      
     
      try {                                                                    
          String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
          String url = "jdbc:odbc:Momqts";
          Class.forName(myDriver);
          conn = DriverManager.getConnection(url);
          stmt = conn.createStatement();
          rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members);
          int sn=0;
          while(rslt.next())
          {
                String mqrid =rslt.getString("Emp_no");
                String mdate=rslt.getString("project_id");
                String mid=rslt.getString("Emp_name");
                sb.append("<TR><TD ALIGN=\"CENTER\">");
                sb.append(mqrid);
                sb.append("</TD><TD ALIGN=\"CENTER\">");
                sb.append(mdate);
                sb.append("</TD><TD ALIGN=\"CENTER\">");
                sb.append(mid);
                sb.append("</TD></TR>\n");
                nameList.add(sb.toString());
          }
      }
     catch(Exception e)
     {                      
         System.err.println(e);                
     }
     finally
     {
          try { if( rslt != null ) rslt.close() ; } catch( SQLException ignored ) {}
          try { if( stmt != null ) stmt.close() ; } catch( SQLException ignored ) {}
          try { if( conn != null ) conn.close() ; } catch( SQLException ignored ) {}
     }
     
%>
<pg:pager items="<%= nameList.size() %>"
          index="center"
          maxPageItems="5"
          maxIndexPages="10"
          isOffset="<%= true %>"
          export="offset,currentPageNumber=pageNumber"
          scope="request">
 
    <input type="hidden" name="pager.offset" value="<%= offset %>">
    <pg:index>
           <jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
    </pg:index>
<TABLE WIDTH="80%" BORDER="1">
    <TR><TH>Name</TH><TH>Age</TH><TH>project</TH></TR>
<%
    for (int i = 0 ; i < nameList.size() ; i++)
    {
%>
    <pg:item><%= (String)nameList.get(i) %></pg:item>
<%
    }
%>
</table>
</form>
</body>
</html>
0
TimYatesCommented:
assuming you've installed jsptags correctly (like it says in http://jsptags.com/tags/navigation/pager/pager-taglib-2.0.html#install_tomcat)
0
kalyanmAuthor Commented:
Tim
Yes
I ahve inserted the tags as required but when I run the above jsp i get the error
org.apache.jasper.JasperException: /ptrial.jsp(85,0) Unterminated &lt;pg:pager&gt; tag
0
TimYatesCommented:
oh yeah...  because you haven't closed the pg:pager tag...

change the bottom of the file to be:

<pg:pager items="<%= nameList.size() %>"
          index="center"
          maxPageItems="5"
          maxIndexPages="10"
          isOffset="<%= true %>"
          export="offset,currentPageNumber=pageNumber"
          scope="request">
 
    <input type="hidden" name="pager.offset" value="<%= offset %>">
    <pg:index>
           <jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
    </pg:index>
<TABLE WIDTH="80%" BORDER="1">
    <TR><TH>Name</TH><TH>Age</TH><TH>project</TH></TR>
<%
    for (int i = 0 ; i < nameList.size() ; i++)
    {
%>
    <pg:item><%= (String)nameList.get(i) %></pg:item>
<%
    }
%>
  </pg:pager>
</table>
</form>
</body>
</html>

hee hee, what a lot of typing for a pre-emptive B grade ;-)
0
kalyanmAuthor Commented:
Tim
Well you certainly deserve more than that...
I get the same error again any ideas
org.apache.jasper.JasperException: /ptrial.jsp(85,0) Unterminated &lt;pg:pager&gt; tag
0
TimYatesCommented:
can you post all of your current code again?
0
kalyanmAuthor Commented:
<html>

<head>
<title> New Document </title>
</head>
<%@ page language="java" import="java.*,java.sql.*,java.util.*,java.io.*" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<body bgcolor="lightblue">
<%
String columnName = request.getParameter( "column" );
if( columnName == null ) columnName = "Emp_no";
%>

<p><font size="6"><strong><font color="#ad1f92">PCNBS</font> </strong></font></p>
<script language="javascript" src="menu.js"></script>

<form name="frmadd" method="post" action="listadd.jsp">
<p>&nbsp;</p>
<%
     ResultSet rslt = null;
     Connection conn =  null ;
     Statement stmt = null ;
     ArrayList nameList = new ArrayList();
     StringBuffer sb = null;      
     
      try {                                                                    
          String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
          String url = "jdbc:odbc:Momqts";
          Class.forName(myDriver);
          conn = DriverManager.getConnection(url);
          stmt = conn.createStatement();
          rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members);
          int sn=0;
          while(rslt.next())
          {
                String mqrid =rslt.getString("Emp_no");
                String mdate=rslt.getString("project_id");
                String mid=rslt.getString("Emp_name");
                sb.append("<TR><TD ALIGN=\"CENTER\">");
                sb.append(mqrid);
                sb.append("</TD><TD ALIGN=\"CENTER\">");
                sb.append(mdate);
                sb.append("</TD><TD ALIGN=\"CENTER\">");
                sb.append(mid);
                sb.append("</TD></TR>\n");
                nameList.add(sb.toString());
          }
      }
     catch(Exception e)
     {                      
         System.err.println(e);                
     }
     finally
     {
          try { if( rslt != null ) rslt.close() ; } catch( SQLException ignored ) {}
          try { if( stmt != null ) stmt.close() ; } catch( SQLException ignored ) {}
          try { if( conn != null ) conn.close() ; } catch( SQLException ignored ) {}
     }
     
%>
<pg:pager items="<%= nameList.size() %>"
          index="center"
          maxPageItems="5"
          maxIndexPages="10"
          isOffset="<%= true %>"
          export="offset,currentPageNumber=pageNumber"
          scope="request">
 
    <input type="hidden" name="pager.offset" value="<%= offset %>">
    <pg:index>
           <jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
    </pg:index>
<TABLE WIDTH="80%" BORDER="1">
    <TR><TH>Name</TH><TH>Age</TH><TH>project</TH></TR>
<%
    for (int i = 0 ; i < nameList.size() ; i++)
    {
%>
    <pg:item><%= (String)nameList.get(i) %></pg:item>
<%
    }
%>
  </pg:pager>
</table>
</form>
</body>
</html>
0
TimYatesCommented:
Sorry, these two are in the wrong order (my mistake)

  </pg:pager>
</table>

swap them like:

  </table>
</pg:pager>
0
kalyanmAuthor Commented:
No joy yet got the same error
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.