• 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

Pagination in JSP

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Am using jsp pagination tags to display the no of employees in the jsp page.When the page loading initially it is displaying records correctly with specified nof records,also no of pages and all.But when am moving for next set of records am getting error because of NULL value for deptno.('deptno' comes from the previous page from request scope, from 2nd time onwards it is becoming NULL)
Please help out how can i make that deptno not to be null .
also is there any anthor approch for pagination

following jsp code am using for dispalying the employee records

<%@ page session="false" %>
<jsp irective.page import="java.util.List,com.emp.*"/>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<html:html>
<body bgcolor="#ffffff">
<%
int maxPageItems = 4;
%>
<form action="<%= request.getRequestURI() %>" method="post">
<pg ager
items="<%=siz %>"
maxPageItems="<%=maxPageItems %>"
isOffset="<%= true %>"
export="offset,currentPageNumber=pageNumber"
scope="request">
<pg aram name="maxPageItems"/>
<pg aram name="maxIndexPages"/>
<%-- save pager offset during form changes --%>
<input type="hidden" name="pager.offset" value="<%= offset %>">
<table width="90%" cellspacing="1" cellpadding="1" border="1">
<tr bgcolor="#6b97e7" style="color:white;font-weight:bold;font-size:12px;">
<td width="30%">Employee Id</td>
<td width="30%">Employee Name</td>
<td width="30%">Employee Salary</td>
</tr>
<%
Employee e=null;

String deptno=(String)request.getParameter("DepartNo")
//Code to retrive the emplyees based on DepartNo
//List li storing in List
siz=li.size();
for (int i = offset.intValue(),
l = Math.min(i +maxPageItems, li.size());
i < l; i++)
{
e=(Employee)li.get(i);
%>
<pg:item>
<tr>
<td><a href=""><%= e.getEmpId() %></a></td>
<td> <%= e.getEmpName() %></td>
<td> <%= e.getEmpSal() %></td>
</tr>
</pg:item>
<%} %>
</table>
<pg:index>
<jsp:include page="/WEB-INF/jsp/altavista.jsp" flush="true"/>
</pg:index>
</pg ager>
</body>
</html:html>
<%!
private static int siz=0;
%>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest you just create an html:hidden tag for the department number. If you do this, it will get carried forward with each form submission.
 
skumar mk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

I did the same what you said still am getting the same ERROR.please help me out from pagination problem.



Thanks in advance.
 
reply
    Bookmark Topic Watch Topic
  • New Topic