java - how to add pagination to jsp -
i have jsp hit database , data of table employee_details eill have 5 columns id,name,department,salary,manager. below jsp displaying whole table want add pagination it.can 1 regarding this
<%@page import="com.symp.dbutil" import="java.sql.*"%> <html> <head> </head> <body> <% connection con; dbutil db; db=new dbutil(); con=db.getoracleconnection("oracle.jdbc.driver.oracledriver",url,username,password); system.out.println("connection "+con); statement st=con.createstatement(); resultset resultset = st.executequery("select * employee_details") ; %> <table id="results" > <tr> <th>employee_id</th> <th>name</th> <th>salary</th> <th>department</th> <th>manager</th> </tr> <% while(resultset.next()){ %> <tr> <td> <%= resultset.getstring(1) %></td> <td> <%= resultset.getstring(2) %></td> <td> <%= resultset.getstring(3) %></td> <td> <%= resultset.getstring(4) %></td> <td> <%= resultset.getstring(5) %></td> </tr> <% } %> </table>
you can use displaytag jsp tag library achieve this:
http://www.displaytag.org/1.2/
however need refactoring either use <sql:query />
tag or put resultset list of beans (both of things regardless using java code scriptlets in jsp pages went out of fashion @ least 10 years ago):
http://www.tutorialspoint.com/jsp/jstl_sql_query_tag.htm
http://www.displaytag.org/1.2/tut_sources.html
and on general point of using scriptlets:
Comments
Post a Comment