• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Paging in JSP

Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 50 values those are comimg from database , but I want only 10 values show at a time and a link next. If I click next, I should go to other next 10 values and so on. How can I achieve it. Pls get back to me soon since I am stuck with problem.

Posts: 15385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you search this forum, you should find that this question is asked all the time. You can find your solution that way.

Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U need to fisrt include the jar -pager-taglib.jar in the lib of the WEB-INF folder

Try modifying this piece of code

<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>

<pg ager
items="<%=DataSize %>"
index="<%= index %>"
maxPageItems="<%= maxPageItems %>"
maxIndexPages="<%= maxIndexPages %>"
isOffset="<%= true %>"

<pg aram name="style"/>
<pg aram name="position"/>
<pg aram name="index"/>
<pg aram name="maxPageItems"/>
<pg aram name="maxIndexPages"/>

int pagemove=0;
if (offset.intValue()>DataSize){
pagemove= offset.intValue();


<% if ("top".equals(position) || "both".equals(position)) { %>
int currpg=pagemove+15;
<font class = "firstlevel" size="2" > DISPLAYING RECORDS  <%=pagemove%>-<%=currpg%>/<%=DataSize%>    


<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=0%>"><nobr>[ First ] </nobr></a>

<pg rev>
<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=pagemove-15%>"><nobr>[ Prev ] </nobr></a>
</pg rev>


<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=pagemove +15%>"><nobr>[ Next ]  </nobr></a>

<a href="/tas/TimeSheetPageMove.do?pager.offset=<%=DataSize-15%> "><nobr>[ Last ] </nobr></a></font>


<% } %>


int a = 0;
<TD colspan="10"><font class = "generalfont">  No records to Display</font></TD>
for (int i = pagemove,
l = Math.min(i + maxPageItems, DataSize);
i < l; i++)


<% System.out.println(((java.util.Properties)(TimeSheet.toArray()[i])).getProperty("status"));
if(((java.util.Properties)(TimeSheet.toArray()[i])).getProperty("status").equals("APPROVED")) { %>
<td><input name="timeid" type="checkbox" disabled="true" value=<%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("timeId")%>></td>
<%} else {%>
<td><input name="timeid" type="checkbox" value=<%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("timeId")%>></td>
<% }%>

<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("projName") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("taskName") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("activity") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("startTime") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("endTime") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("duration") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("status") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("date") %></font></TD>
<TD><font class = "generalfont">  <%=((java.util.Properties)TimeSheet.toArray()[i]).getProperty("Comment") %></font></TD>


</pg ager>

Hope this is of some help

    Bookmark Topic Watch Topic
  • New Topic