i am unable to do pagination in jsp. please help me ..
i have a database named mytable where i have a table named student(rollNo , name , marks , grade) i connect to the database using the following code named connect.java which is in a package named common :
when i run it on netbeans i get the following error report on my browser :
HTTP Status 500 -
type Exception report
description The server encountered an internal error () that prevented it from fulfilling this request.
org.apache.jasper.JasperException: An exception occurred processing JSP page /pagination.jsp at line 47
44: connect c = new connect();
45: con = c.getConnection();
46: String query1 = "SELECT SQL_CALC_FOUND_ROWS * FROM student limit " + iPageNo + "," + showRows + "";
47: ps1 = con.prepareStatement(query1);
48: rs1 = ps1.executeQuery();
50: String query2 = "SELECT FOUND_ROWS() as cnt";
William P O'Sullivan wrote:Looks like your Connection con is null at line 45.
Why do you not have a null check on it prior to preparing the statement.
Also, there is way too much Java scriptlets in this JSP.
Thank you for your reply WP. I admit the code has too much sciplets in it which is not fair.. but through the net i have found nothing that suits my necessity in generating pagination.. So please help me with some code.
I would suggest to refactor your code and move Pagination logic in java class and call this class in some pagination.jsp and include that pagination.jsp wherever you need pagination. it will make your jsp more cohesive.