Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pagination in JSP

 
skumar mk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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;
%>
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic