<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JSP Pagination</title>
	<atom:link href="http://www.easywayserver.com/blog/jsp-pagination/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.easywayserver.com/blog/jsp-pagination/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 15 Jan 2012 15:24:27 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Michael</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-48508</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 05 Dec 2011 20:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-48508</guid>
		<description>Please guys am new to J2EE I want to paginate a large result set with JSTL from an SQL query am using MySQL for eg. if i have 50 records in my DB and i need only 10 records at a time then i will have a next and previous links to go through the records my sql query looks like this



SELECT * FROM employee LIMIT 0, 10






${employee.firstname}


</description>
		<content:encoded><![CDATA[<p>Please guys am new to J2EE I want to paginate a large result set with JSTL from an SQL query am using MySQL for eg. if i have 50 records in my DB and i need only 10 records at a time then i will have a next and previous links to go through the records my sql query looks like this</p>
<p>SELECT * FROM employee LIMIT 0, 10</p>
<p>${employee.firstname}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: divya</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-24313</link>
		<dc:creator>divya</dc:creator>
		<pubDate>Fri, 19 Aug 2011 11:02:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-24313</guid>
		<description>Great Tutorial.....u explained everything in a very easiest and possible way</description>
		<content:encoded><![CDATA[<p>Great Tutorial&#8230;..u explained everything in a very easiest and possible way</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lakshmi</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-24259</link>
		<dc:creator>lakshmi</dc:creator>
		<pubDate>Thu, 18 Aug 2011 06:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-24259</guid>
		<description>&lt;!-- sample.jsp --&gt;










Pagination of JSP page




&lt;input type=&quot;hidden&quot; name=&quot;iPageNo&quot; value=&quot;&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;cPageNo&quot; value=&quot;&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;iShowRows&quot; value=&quot;&quot;&gt;


Name
Batch
Address


   &lt;!-- names from the table you have queried and what you want to be displayed in the result --&gt;
      
      
      
    
    
&lt;%
  //// calculate next record start record  and end record 
        try{
            if(iTotalRows



0)
        {
         %&gt;

          &lt;a href=&quot;sample.jsp?iPageNo=&amp;cPageNo=&quot;&gt; &lt;&lt; Previous&lt;/a&gt;
         &lt;%
        }
        
        for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i
           &lt;a href=&quot;sample.jsp?iPageNo=&quot; style=&quot;cursor:pointer;color: red&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/a&gt;
          &lt;%
          }
          else if(i
           &lt;a href=&quot;sample.jsp?iPageNo=&quot;&gt;&lt;/a&gt;
          iTotalSearchRecords &amp;&amp; i
         &lt;a href=&quot;sample.jsp?iPageNo=&amp;cPageNo=&quot;&gt; &gt;&gt; Next&lt;/a&gt; 
         
&lt;b&gt;Rows  -    Total Result   &lt;/b&gt;







</description>
		<content:encoded><![CDATA[<p><!-- sample.jsp --></p>
<p>Pagination of JSP page</p>
<p>&lt;input type=&quot;hidden&quot; name=&quot;iPageNo&quot; value=&quot;&#8221;&gt;<br />
&lt;input type=&quot;hidden&quot; name=&quot;cPageNo&quot; value=&quot;&#8221;&gt;<br />
&lt;input type=&quot;hidden&quot; name=&quot;iShowRows&quot; value=&quot;&#8221;&gt;</p>
<p>Name<br />
Batch<br />
Address</p>
<p>   <!-- names from the table you have queried and what you want to be displayed in the result --></p>
<p>&lt;%<br />
  //// calculate next record start record  and end record<br />
        try{<br />
            if(iTotalRows</p>
<p>0)<br />
        {<br />
         %&gt;</p>
<p>          &lt;a href=&quot;sample.jsp?iPageNo=&amp;cPageNo=&#8221;&gt; &lt;&lt; Previous<br />
         &lt;%<br />
        }</p>
<p>        for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<br />
           &lt;a href=&quot;sample.jsp?iPageNo=&#8221; style=&#8221;cursor:pointer;color: red&#8221;&gt;<b></b><br />
          &lt;%<br />
          }<br />
          else if(i<br />
           &lt;a href=&quot;sample.jsp?iPageNo=&#8221;&gt;<br />
          iTotalSearchRecords &amp;&amp; i<br />
         &lt;a href=&quot;sample.jsp?iPageNo=&amp;cPageNo=&#8221;&gt; &gt;&gt; Next </p>
<p><b>Rows  &#8211;    Total Result   </b></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lakshmi</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-24257</link>
		<dc:creator>lakshmi</dc:creator>
		<pubDate>Thu, 18 Aug 2011 06:42:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-24257</guid>
		<description>Hi Swamy

index.jsp is the same page what you are viewing</description>
		<content:encoded><![CDATA[<p>Hi Swamy</p>
<p>index.jsp is the same page what you are viewing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tom</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-20804</link>
		<dc:creator>tom</dc:creator>
		<pubDate>Wed, 11 May 2011 10:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-20804</guid>
		<description>can anybody tell me that from where you are retrieving rows from database??? plz tell me that from where you are bringing Name, Batch and Address? From where you are bringing these:


      
      </description>
		<content:encoded><![CDATA[<p>can anybody tell me that from where you are retrieving rows from database??? plz tell me that from where you are bringing Name, Batch and Address? From where you are bringing these:</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-20349</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 26 Apr 2011 19:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-20349</guid>
		<description>Iv been looking for a nice pagination script for several hours and finally i come to yours
THANK GOD!!! very nice :)</description>
		<content:encoded><![CDATA[<p>Iv been looking for a nice pagination script for several hours and finally i come to yours<br />
THANK GOD!!! very nice <img src='http://www.easywayserver.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajivia</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-20132</link>
		<dc:creator>Rajivia</dc:creator>
		<pubDate>Tue, 19 Apr 2011 09:43:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-20132</guid>
		<description>When i try above code i get an exception which is like this:---
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/pagination.jsp at line 66

63:     
64:     String sqlPagination=\&quot;SELECT SQL_CALC_FOUND_ROWS * FROM REG limit \&quot;+iPageNo+\&quot;,\&quot;+iShowRows+\&quot;\&quot;;
65: 
66:     psPagination=conn.prepareStatement(sqlPagination);
67:     rsPagination=psPagination.executeQuery();
68:     
69:     //// this will count total number of rows


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)</description>
		<content:encoded><![CDATA[<p>When i try above code i get an exception which is like this:&#8212;<br />
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/pagination.jsp at line 66</p>
<p>63:<br />
64:     String sqlPagination=\&quot;SELECT SQL_CALC_FOUND_ROWS * FROM REG limit \&quot;+iPageNo+\&quot;,\&quot;+iShowRows+\&quot;\&quot;;<br />
65:<br />
66:     psPagination=conn.prepareStatement(sqlPagination);<br />
67:     rsPagination=psPagination.executeQuery();<br />
68:<br />
69:     //// this will count total number of rows</p>
<p>Stacktrace:<br />
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)<br />
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)<br />
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)<br />
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)<br />
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adit</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-19313</link>
		<dc:creator>adit</dc:creator>
		<pubDate>Sat, 26 Mar 2011 04:58:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-19313</guid>
		<description>where do these parameter be initialized??   

 int iTotalRows=nullIntconv(request.getParameter(&quot;iTotalRows&quot;));
    int iTotalPages=nullIntconv(request.getParameter(&quot;iTotalPages&quot;));
    int iPageNo=nullIntconv(request.getParameter(&quot;iPageNo&quot;));
    int cPageNo=nullIntconv(request.getParameter(&quot;cPageNo&quot;));</description>
		<content:encoded><![CDATA[<p>where do these parameter be initialized??   </p>
<p> int iTotalRows=nullIntconv(request.getParameter(&#8221;iTotalRows&#8221;));<br />
    int iTotalPages=nullIntconv(request.getParameter(&#8221;iTotalPages&#8221;));<br />
    int iPageNo=nullIntconv(request.getParameter(&#8221;iPageNo&#8221;));<br />
    int cPageNo=nullIntconv(request.getParameter(&#8221;cPageNo&#8221;));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajni</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-18492</link>
		<dc:creator>Rajni</dc:creator>
		<pubDate>Thu, 24 Feb 2011 17:31:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-18492</guid>
		<description>function fnPage(CurrentPage){

	document.frmProduct.CurrentPage.value=CurrentPage;
	document.frmProduct.action=&quot;&quot;;
	document.frmProduct.submit();
}

function fnPagetxt(totalpage){
	var page=document.frmProduct.pageNo.value;
	if(isNaN(page)){
		alert(&quot;Please Enter a Number&quot;);
		document.frmProduct.pageNo.value=&quot;&quot;;
		return false;
	}
	if(page&gt;totalpage ){
		alert(&quot;Please Enter a Number &lt;=&quot;+totalpage);
		document.frmProduct.pageNo.value=&quot;&quot;;
		return false;
	}
	if(page0&quot;);
		document.frmProduct.pageNo.value=&quot;&quot;;
		return false;
	}
	document.frmProduct.CurrentPage.value=page;
	document.frmProduct.action=&quot;&quot;;
	document.frmProduct.submit();
}



String CurrPage=(request.getParameter(&quot;CurrentPage&quot;)==null?&quot;1&quot;:request.getParameter(&quot;CurrentPage&quot;));




int noOfpage=0;
	int CurrentPageNo=0;
	int RecordNo=0;
	int Start=0;
	int End=0;
	int[] dropdown = new int[] {10,25,50};
	int recordsperpage=Integer.parseInt(SelectedDrop);
	if(!CurrPage.equals(&quot;&quot;)){
		CurrentPageNo=Integer.parseInt(CurrPage);
	}



if(!SelectedBUC.equals(&quot;&quot;) &amp;&amp; !BillingYear.equals(&quot;&quot;))
	{
		totalrecords=fabrutil.getRecordCount(SelectedBUC,BillingYear);
		noOfpage=totalrecords/recordsperpage;
		if((totalrecords%recordsperpage)!=0){
			noOfpage=noOfpage+1;
		}
	}



if(!SelectedDecCode.equals(&quot;&quot;) &amp;&amp; !SelectedBUC.equals(&quot;&quot;) &amp;&amp; !BillingYear.equals(&quot;&quot;) &amp;&amp; !SelectedLocation.equals(&quot;&quot;))
	{
		RecordNo=fabrutil.getRecordNumber(SelectedBUC,BillingYear,SelectedDecCode,SelectedLocation);
		CurrentPageNo=RecordNo/recordsperpage;
		if((recordsperpage*CurrentPageNo)!=RecordNo)
		{
			CurrentPageNo=CurrentPageNo+1;
		}
	}
	String StartIndex=((CurrentPageNo-1)*recordsperpage+1)+&quot;&quot;;
	String EndIndex=(CurrentPageNo*recordsperpage)+&quot;&quot;;
	if(CurrentPageNo==noOfpage){
		EndIndex=totalrecords+&quot;&quot;;
	}


if(CurrentPageNo&lt;4 &#124;&#124; noOfpage1 &amp;&amp; noOfpage(noOfpage-3)){
		Start=noOfpage-4;
		End=noOfpage;
	}else{
		Start=CurrentPageNo-2;
		End=CurrentPageNo+2;
	}




0){
		if(Start&gt;0){
%&gt;
	
	
	&lt;B&gt;Records - of &lt;/B&gt;
	&#160;
	&lt;B&gt;Page &#160;of&#160;&lt;/B&gt;
	
	
	
	&lt;B&gt;Records Per Page&lt;/B&gt;
	
		&lt;%for(int i=0;i
			&lt;option value=&quot;&quot;  selected &gt;
		
	
	
	
	1)
		{ %&gt;
		
		&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt; &lt;B&gt; &#124;&lt; First &#160;&#160;&#160; &lt;/B&gt; &lt;/a&gt;
	5){ %&gt;
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&quot;);&#039; align=&quot;left&quot;&gt; &lt;B&gt; &lt; Previous 5&#160;&#160;&#160; &lt;/B&gt; &lt;/a&gt;
	&lt;%	}
		for (int i=Start; i
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&quot;);&#039;&gt; &lt;B&gt;&#160;&lt;/B&gt;&lt;/a&gt;
		
		&lt;B&gt;&#160;&lt;/B&gt;
		&lt;%} } if(End
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&quot;);&#039; align=&quot;left&quot;&gt; &lt;B&gt;&#160;&#160;&#160; Next 5&gt; &lt;/B&gt; &lt;/a&gt;
		&lt;%}if(End
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&quot;);&#039;&gt; &lt;B&gt;&#160;&#160;&#160;Last &gt;&#124; &lt;/B&gt;&lt;/a&gt;
		
		
		
		=10){%&gt;
		&lt;b&gt;Page No(&lt;= ) &lt;/b&gt;
		
		&lt;input type=&quot;button&quot; name=&quot;GO&quot; value=&quot;GO&quot; onclick=&quot;fnPagetxt();&quot;&gt;
		
		
		
	</description>
		<content:encoded><![CDATA[<p>function fnPage(CurrentPage){</p>
<p>	document.frmProduct.CurrentPage.value=CurrentPage;<br />
	document.frmProduct.action=&#8221;";<br />
	document.frmProduct.submit();<br />
}</p>
<p>function fnPagetxt(totalpage){<br />
	var page=document.frmProduct.pageNo.value;<br />
	if(isNaN(page)){<br />
		alert(&#8221;Please Enter a Number&#8221;);<br />
		document.frmProduct.pageNo.value=&#8221;";<br />
		return false;<br />
	}<br />
	if(page&gt;totalpage ){<br />
		alert(&#8221;Please Enter a Number &lt;=&quot;+totalpage);<br />
		document.frmProduct.pageNo.value=&quot;&quot;;<br />
		return false;<br />
	}<br />
	if(page0&#8243;);<br />
		document.frmProduct.pageNo.value=&#8221;";<br />
		return false;<br />
	}<br />
	document.frmProduct.CurrentPage.value=page;<br />
	document.frmProduct.action=&#8221;";<br />
	document.frmProduct.submit();<br />
}</p>
<p>String CurrPage=(request.getParameter(&#8221;CurrentPage&#8221;)==null?&#8221;1&#8243;:request.getParameter(&#8221;CurrentPage&#8221;));</p>
<p>int noOfpage=0;<br />
	int CurrentPageNo=0;<br />
	int RecordNo=0;<br />
	int Start=0;<br />
	int End=0;<br />
	int[] dropdown = new int[] {10,25,50};<br />
	int recordsperpage=Integer.parseInt(SelectedDrop);<br />
	if(!CurrPage.equals(&#8221;")){<br />
		CurrentPageNo=Integer.parseInt(CurrPage);<br />
	}</p>
<p>if(!SelectedBUC.equals(&#8221;") &amp;&amp; !BillingYear.equals(&#8221;"))<br />
	{<br />
		totalrecords=fabrutil.getRecordCount(SelectedBUC,BillingYear);<br />
		noOfpage=totalrecords/recordsperpage;<br />
		if((totalrecords%recordsperpage)!=0){<br />
			noOfpage=noOfpage+1;<br />
		}<br />
	}</p>
<p>if(!SelectedDecCode.equals(&#8221;") &amp;&amp; !SelectedBUC.equals(&#8221;") &amp;&amp; !BillingYear.equals(&#8221;") &amp;&amp; !SelectedLocation.equals(&#8221;"))<br />
	{<br />
		RecordNo=fabrutil.getRecordNumber(SelectedBUC,BillingYear,SelectedDecCode,SelectedLocation);<br />
		CurrentPageNo=RecordNo/recordsperpage;<br />
		if((recordsperpage*CurrentPageNo)!=RecordNo)<br />
		{<br />
			CurrentPageNo=CurrentPageNo+1;<br />
		}<br />
	}<br />
	String StartIndex=((CurrentPageNo-1)*recordsperpage+1)+&#8221;";<br />
	String EndIndex=(CurrentPageNo*recordsperpage)+&#8221;";<br />
	if(CurrentPageNo==noOfpage){<br />
		EndIndex=totalrecords+&#8221;";<br />
	}</p>
<p>if(CurrentPageNo&lt;4 || noOfpage1 &amp;&amp; noOfpage(noOfpage-3)){<br />
		Start=noOfpage-4;<br />
		End=noOfpage;<br />
	}else{<br />
		Start=CurrentPageNo-2;<br />
		End=CurrentPageNo+2;<br />
	}</p>
<p>0){<br />
		if(Start&gt;0){<br />
%&gt;</p>
<p>	<b>Records &#8211; of </b><br />
	&nbsp;<br />
	<b>Page &nbsp;of&nbsp;</b></p>
<p>	<b>Records Per Page</b></p>
<p>		&lt;%for(int i=0;i<br />
			&lt;option value=&quot;&#8221;  selected &gt;</p>
<p>	1)<br />
		{ %&gt;</p>
<p>		<a href="#" rel="nofollow"> <b> |&lt; First &nbsp;&nbsp;&nbsp; </b> </a><br />
	5){ %&gt;<br />
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&#8221;);&#8217; align=&#8221;left&#8221;&gt; <b> &lt; Previous 5&nbsp;&nbsp;&nbsp; </b><br />
	&lt;%	}<br />
		for (int i=Start; i<br />
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&#8221;);&#8217;&gt; <b>&nbsp;</b></p>
<p>		<b>&nbsp;</b><br />
		&lt;%} } if(End<br />
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&#8221;);&#8217; align=&#8221;left&#8221;&gt; <b>&nbsp;&nbsp;&nbsp; Next 5&gt; </b><br />
		&lt;%}if(End<br />
		&lt;a href=&quot;#&quot; onclick=&#039;javascript:fnPage(&quot;&#8221;);&#8217;&gt; <b>&nbsp;&nbsp;&nbsp;Last &gt;| </b></p>
<p>		=10){%&gt;<br />
		<b>Page No(&lt;= ) </b></p>
<p>		&lt;input type=&quot;button&quot; name=&quot;GO&quot; value=&quot;GO&quot; onclick=&quot;fnPagetxt();&#8221;&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sa.Vejeykummar</title>
		<link>http://www.easywayserver.com/blog/jsp-pagination/comment-page-1/#comment-16783</link>
		<dc:creator>Sa.Vejeykummar</dc:creator>
		<pubDate>Wed, 05 Jan 2011 11:53:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=12#comment-16783</guid>
		<description>Thank u.</description>
		<content:encoded><![CDATA[<p>Thank u.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

