SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bauke Scholtz wrote:Crossposted: http://forums.sun.com/thread.jspa?threadID=5358615
Please read this: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
Ankit Garg wrote:I think this condition is creating the problems.
Here you are setting the count attribute for the second time. And this will hurt you only when the size of products is < 24 i.e. the actual number of records to be shown on each page...
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:First of all remove the code which I pointed out then it will run fine.
When you set the attribute for the second time, the value that was set earlier will be removed. This creates problems. Suppose the last page has 12 records. When you set count for the second time, then it will behave as if 12 records should be shown on each page. So the loop in your JSP will run double times. So if 4 page numbers should have been printed, then 8 will be displayed...
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:Yes! You are right. If you change the value of count, then the calculation in the jsp
<c:set var="endcount" value="${itemCount / count}" scope="page"/>
will fail. Suppose the size of products is 12 i.e. the last page has 12 records and total there are 96 records. Then total number of pages should be 4. But since you set count to 12, so itemCount / count will be 96 / 12 i.e. 8. So it will display 8 page numbers...
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:John just remove that line and then the code will run fine. The problem is in the servlet dude...
Don't get me started about those stupid light bulbs. |