<%@ page language="java" %> <%@ page import="java.sql.*" %> <%! public int nullIntconve" name="description">




showing missing expression.pls correct it <%@ page contentType="text/html;charset=windows-1252"%> <%@ page language="java" %> <%@ page import="java.sql.*" %> <%! public int nullIntconvert(String str){ int num=0; if(str==null) { str="0"; } else if((str.trim()).equals("null")) { str="0"; } else if(str.equals("")) { str="0"; } try{ num=Integer.parseInt(str); } catch(Exception e) { } return num; } %> <% Connection conn = null; Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); conn = DriverManager.getConnection("jdbc:oracle:thin:@","Industry","Retail"); ResultSet rs1 = null; ResultSet rs2 = null; PreparedStatement ps1=null; PreparedStatement ps2=null;

int showRows=10; int totalRecords=10; int totalRows=nullIntconvert(request.getParameter("totalRows")); int totalPages=nullIntconvert(request.getParameter("totalPages")); int iPageNo=nullIntconvert(request.getParameter("iPageNo")); int cPageNo=nullIntconvert(request.getParameter("cPageNo"));

int startResult=0; int endResult=0; if(iPageNo==0) { iPageNo=0; } else{ iPageNo=Math.abs((iPageNo-1)*showRows); } String query1="SELECT SQLCALCFOUND_ROWS * FROM Industry.Territory limit "+iPageNo+","+showRows+""; ps1=conn.prepareStatement(query1); rs1=ps1.executeQuery();

String query2="SELECT FOUND_ROWS() as cnt"; ps2=conn.prepareStatement(query2); rs2=ps2.executeQuery(); if(rs2.next()) { totalRows=rs2.getInt("cnt"); } %>

Pagination of JSP page

<% while(rs1.next()) { %> <% } %> <% try{ if(totalRows<(iPageNo+showRows)) { endResult=totalRows; } else{ endResult=(iPageNo+showRows); } startResult=(iPageNo+1); totalPages=((int)(Math.ceil((double)totalRows/showRows))); } catch(Exception e){ e.printStackTrace(); } %>
Terr_Code Terr_Name
<%=rs1.getString("Terr_cd")%> <%=rs1.getString("Terr_name")%>
<% int i=0; int cPage=0; if(totalRows!=0) { cPage=((int)(Math.ceil((double)endResult/(totalRecords*showRows)))); int prePageNo=(cPage*totalRecords)-((totalRecords-1)+totalRecords); if((cPage*totalRecords)-(totalRecords)>0){ %> << Previous <% } for(i=((cPage*totalRecords)-(totalRecords-1));i<=(cPage*totalRecords);i++){ if(i==((iPageNo/showRows)+1)){ %> <%=i%> <% } else if(i<=totalPages){ %> <%=i%> <% } } if(totalPages>totalRecords && i >> Next <% } } %> Rows <%=startResult%> - <%=endResult%> Total Rows <%=totalRows%>

<% try{ if(ps1!=null){ ps1.close(); } if(rs1!=null){ rs1.close(); }

if(ps2!=null){ ps2.close(); } if(rs2!=null){ rs2.close(); }

if(conn!=null){ conn.close(); } } catch(Exception e) { e.printStackTrace(); } %>

View Answers


Related Tutorials/Questions & Answers:
Pagination  How to create pagination in jsp with EJB using MS SQL
Pagination  How to implement pagination in struts using hibernate
Pagination  How to apply pagination in JSP. Please help
pagination  How to set pagination using java script to display data
pagination   Simple way for pagination in jsp using java script to display data without send database
Pagination  Is their plug n play approach for creating pagination? 1) Server side as well as client side
Pagination  I want to write one where condition in sql query in pagination concept
Pagination  I want to know how to use pagination in jsp. I have a list object from that i want to display 3 questions per page can u help me
pagination  I need to give pagination with where condition (query="select * from qtn where qid='"+replyQuesionId+"'limit "+iPageNo+","+showRows+"" ) like this I want, without where condition it is working but with condition
pagination  I need to give pagination with where condition (query.......   Here is a simple jsp pagination code where we have used mysql database...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
=rs2.getInt("cnt"); } %> Pagination of JSP page Terr_Code Terr_Name
pagination  how can i start pagination in jsp?   Hi Friend, Try the following code: <%@ page language="java" %> <%@ page import...;Pagination of JSP page</h3> <body> <form> <input type="hidden
Pagination  pagination in jsp   Hi Friend, Try the following code: <%@ page language="java" %> <%@ page import="java.sql.*" %>...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
code of pagination. In the given code,we have taken the database table student...;Pagination of JSP page</h3> <body> <form> <input type="hidden
Pagination in java
Pagination in java  How to handle pagination when there are records like say in millions in java? Or do we handle this using SQL? I as asked... far good performance then Java pagination. Thanks
pagination in jsf
pagination in jsf  Hi , i am implemeting an online exam system , i have placed my questions as an arraylist in my jsp file within tag , but now i want to paginate these questions based on respective questions by clicking
jsp pagination
jsp pagination  I want to implement pagination on jsp page Each jsp page having some radio buttons, on click of next previous page selected radio buttons are reset. I want to maintain state of selected radio buttons on previous
Hibernate Pagination
In this tutorial we will discuss concept of pagination in hibernate
JSP Pagination
to be shown, I want to implement Pagination.. Can someone show me a sample code which I could possibly use??   JSP Pagination pagination.jsp: <%@ page..."); } %> <html><h3>Pagination of JSP page</h3> <body><
Pagination in jsp - JSP-Servlet
Pagination in jsp  I need an example of pagination in JSP using display tag
jsf pagination
of pagination. In the given code,we have taken the database table student(rollNo,name,marks...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
JTable Pagination
JTable Pagination  Hello , I have the following Code. I am able to fetch the Data from the Database. But i need to implement pagination for the same. Can someone please help me out with this ? I have tried out many things from
Two Pagination in one page
Two Pagination in one page  hai friends any one help me. how do u make two pagination script in same page i'm used some ajax coding one pagination script is working but another pagination is not working please help me urgent
pagination in hibernate with jsp
pagination in hibernate with jsp  Hi, plz give me example on pagination .   Hi Friend, Visit Here Thanks
Pagination example with html code
Pagination example with html code  Hi, could u please provide pagination code with clear cut explanation. Thanks in advance
pagination - JSP-Servlet
pagination  Hi, could u tell me how i will handle pagination... friend, Simple pagination in jsp Simple pagination in JSP... Simple pagination in jsp Displaying Records
pagination in jsp - JDBC
pagination in jsp  Hi, I have millions of records in my oracle d... in advance...   Hi friend, This is simple code of pagination. Simple pagination in jsp
pagination+dynamic pagesize+hibernate - Struts
pagination+dynamic pagesize+hibernate  pagination using hibernate with dynamic page size plzz heilp me