File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Paging Mechanism Without Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Paging Mechanism Without Component " Watch "Paging Mechanism Without Component " New topic
Author

Paging Mechanism Without Component

Jai Shankar
Greenhorn

Joined: Feb 12, 2001
Posts: 2
Here is a Stuff that u can use it for Previous-Next for Paging Mechanism for Moving thru RecordSet
<%@ page language="java"%>
<%@ page errorPage="error.jsp"%>
<%@ page import="java.sql.*,sun.jdbc.odbc.*" %>
<%!
ResultSet rs;
String a,b,c,d,tmp;
int pagesize=5;
int cp;
%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc dbc:jsptest","java","java");
Statement st=con.createStatement();
tmp=request.getParameter("mode");
if(tmp==null)
{
tmp="test";
}
//tmp=tmp.toString();
%>
<%if(tmp.equals("prev"))
{
cp=cp-1;
out.println("333");
}
else if(tmp.equals("next"))
{
cp=cp+1;
out.println("555");
}
else
{
cp=1;
out.println("666");
}
%>
<%out.println(cp);%>
<%
rs=st.executeQuery("SELECT * FROM course");
%>
<% int x=cp-1 * pagesize;
for(int i= 1;i<x;i++)
{
rs.next();
}
%>
<table border=0 cellpadding=2 cellspacing=2 width=100%>
<%
int c1=0;
out.println("Hello OUTside the ");
while(rs.next() && c1<pagesize)
{
out.println("Hello Inside the ");
%>
<tr>
<%
a=rs.getString("campus");
b=rs.getString("code");
c=rs.getString("DegreeTitle");
d=rs.getString("DegreeAwarded");
%>
<td align="center" vAlign="top" bgcolor="beige"><font face="verdana" size="1.5"><%= a%></b></font></td>
<td align="center" vAlign="top" bgcolor="beige"><font face="verdana" size="1.5"><%= b%></b></font></td>
<td align="center" vAlign="top" bgcolor="beige"><font face="verdana" size="1.5"><%= c%></b></font></td>
<td align="center" vAlign="top" bgcolor="beige"><font face="verdana" size="1.5"><a href="<%= d%>">More</a></b></font></td>
</tr>
<%
rs.next();
c1=c1+1;
}
%>
<A href="prevnext1.jsp?mode=prev"><< Previous Page</a>
<A href="prevnext1.jsp?mode=next">Nextpage>></a>
</table>
</body>
</html>


------------------
Jai Shankar
Greenhorn

Joined: Feb 12, 2001
Posts: 2
Its very useful and Time Saving Code
Use it
this JSP page takes place in All E-commerce Application ,No need to Use DATAOBJECTS as in ASP
 
 
subject: Paging Mechanism Without Component
 
Similar Threads
exception java.sql.SQLException: Exhausted Resultset
how to connect to database and display query vqlus using proper java/jsp
Pagination in Servlets from a Resultset
inserting data to a table
exception java.sql.SQLException: Exhausted Resultset