A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
pagination in jsp
ajay madhav
Greenhorn
Joined: May 12, 2008
Posts: 1
posted
May 12, 2008 07:41:00
0
Hi All,
i am new in jsp. I want to give paginaiton using jsp in my application. I am able to show the records in browser. I want to display 5 records per page. I want to display them in google style like:
<<1 2 3 >>next
I am attatching my code herewith:
<%@ page import="java.sql.*" %>
<%
String
driverClass="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/Test";
String userName="root";
String password="";
String user="";
String pword="";
Class.forName(driverClass);
Connection con=DriverManager.getConnection(url,userName,password);
out.println("Connection is established");
//String query="select * from userDetails ";
int count = 5;
String query="select * from userdetails limit "+count+" ";
Statement stm=con.createStatement();
ResultSet
rs=stm.executeQuery(query);
out.println("Resultset created");%>
<table border=1 align=center width="100%">
<tr><th>username</th><th>password</th></tr>
<%
while(rs.next()){
user=rs.getString(1);
pword=rs.getString(2);
%>
<tr><td><%=user%></td><td><%=pword%></td></tr><%}%>
</table>
I am also giving my table structure:
tablename is 'userdetails'
fields are 'username, password, address'
It's very urgent for me.I will be very thankful for this help
Thanks in advance
Ajay Madhav
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
I like...
posted
May 12, 2008 07:44:00
0
See:
http://faq.javaranch.com/java/PaginationOrPaging
Java API
J2EE API
Servlet Spec
JSP Spec
How to ask a question...
Simple Servlet Examples
jsonf
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
I like...
posted
May 12, 2008 07:45:00
0
Originally posted by ajay madhav:
It's very urgent for me.
Please also see:
EaseUp
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: pagination in jsp
Similar Threads
Sending Email from jsp page
Getting Problem in Delete operation in Struts application
what could be the reason behind this exception?
Calling another servlet
Trouble connecting to MS Access via ODBC
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter