paging in JSP using logic:iterate

I need program for paging in JSP using logic:iterate and struts ,and <b><h3> do not want to use the third party tags </b></h3>
mgoutham22Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

fargoCommented:
u can make use of pager taglibrary
http://jsptags.com

Check out the site documentation for setting up etc...

following is the ex. template
<%@ page contentType="text/html;charset=ISO-8859-1" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/pager-taglib.tld" prefix="pg" %>

<!-- Making use of page tag library -->
<pg:pager maxIndexPages="25" maxPageItems="20" export="currentPageNumber=pageNumber">
  <pg:param name="pg"/>
  <pg:param name="q"/>

<center>
<logic:present name="someList">
<logic:notEmpty name="someList">
    <logic:iterate id="element" name="someList">
      <pg:item>
      <tr><td>...</td><td></td> ........</tr>
      <tr><td>...</td><td></td> ........</tr>
      <tr><td>...</td><td></td> ........</tr>
      ......
      </pg:item>
       </logic:iterate>
    </logic:notEmpty>
<logic:empty name="someList" >
.....
</logic:empty>
</logic:present>
</table>
</center>
<br />
<center>
<!-- this is for page indexing ** starts here**-->
  <pg:index>
    <font face=Helvetica size=-1 color=ActiveCaption>Result Pages:
    <pg:prev>&nbsp;<a href="<bean:write name="pageUrl" />" style="text-decoration:none">[&lt;&lt; Prev]</a></pg:prev>
    <pg:pages><%
      if (pageNumber.intValue() < 10) {
        %>&nbsp;<%
      }
      if (pageNumber == currentPageNumber) {
        %><b><%= pageNumber %></b><%
      } else {
        %><a href="<bean:write name="pageUrl" />" style="text-decoration:none"><%= pageNumber %></a><%
      }
    %>
    </pg:pages>
    <pg:next>&nbsp;<a href="<bean:write name="pageUrl" />" style="text-decoration:none">[Next &gt;&gt;]</a></pg:next>
    <br></font>
  </pg:index>
</pg:pager>
</center>
</body>
</html:html>

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
fargoCommented:
You can have a look here
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21777860.html

i helped someone to get it done. Please go thru it and let us know if u face problems.
mgoutham22Author Commented:
i Knew that , but I am very much restricted in using the third party tags, Thanks any way.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

fargoCommented:
Then best bet is to have a database based paging. In mysql u can make use of LIMIT clause and in Oracle you can make use of rownum.
mgoutham22Author Commented:
ok here is the the complete situation, I have a arraylist size is 20 and need to display 5 a page . it is not some thing related to the database.

I need to write a program using the logic iterate and struts action class.
fargoCommented:
ok. for such a small list..u don't really need db. try with the following
1st page
<logic:iterate id="element" name="someList" offset="1" length="5">
...
</logic:iterate>

2nd page
<logic:iterate id="element" name="someList" offset="6" length="5">
...
</logic:iterate>
and -.....

generate the pager links...and add offset as parameter to make a generalise handling.
mgoutham22Author Commented:
The list size is not fixed.
mgoutham22Author Commented:
List size will be less than or equal to 20 .
fargoCommented:
there is no handling with the list size. Why do u have doubts with list size? Only thing we did is set the offset and length to display till 5.
mgoutham22Author Commented:
let me try it
fargoCommented:
the provided solution by me does work. Points should be awarded to me.
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.