wood burning stoves 2.0
The moose likes Struts and the fly likes Pagination in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pagination in JSP" Watch "Pagination in JSP" New topic

Pagination in JSP

skumar mk

Joined: Jul 02, 2008
Posts: 12
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" %>
<body bgcolor="#ffffff">
int maxPageItems = 4;
<form action="<%= request.getRequestURI() %>" method="post">
<pg ager
items="<%=siz %>"
maxPageItems="<%=maxPageItems %>"
isOffset="<%= true %>"
<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>
Employee e=null;

String deptno=(String)request.getParameter("DepartNo")
//Code to retrive the emplyees based on DepartNo
//List li storing in List
for (int i = offset.intValue(),
l = Math.min(i +maxPageItems, li.size());
i < l; i++)
<td><a href=""><%= e.getEmpId() %></a></td>
<td> <%= e.getEmpName() %></td>
<td> <%= e.getEmpSal() %></td>
<%} %>
<jsp:include page="/WEB-INF/jsp/altavista.jsp" flush="true"/>
</pg ager>
private static int siz=0;
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
skumar mk

Joined: Jul 02, 2008
Posts: 12
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Pagination in JSP
It's not a secret anymore!