aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pagination in JSP" Watch "Pagination in JSP" New topic
Author

Pagination in JSP

skumar mk
Greenhorn

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" %>
<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

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.


Merrill
Consultant, Sima Solutions
skumar mk
Greenhorn

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Pagination in JSP
 
Similar Threads
jsp tag pagination and tiles
Why it can't paging?!
Pagination issue
Paging in JSP
Pagination?