The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
creating a new page with a link to it
Discuss creating a new page with a link to it in the Java Help forum on Dev Shed. creating a new page with a link to it Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 11th, 2002, 06:06 PM
|
|
Registered User
|
|
Join Date: Feb 2002
Posts: 20
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
creating a new page with a link to it
Hi
I'm a beginner. I'm trying to display a fix number of records per page say for example 10 records per page. If it exceeds 10 records it will place the rest of the records in a new page with a link to the new page while the new page contains the link to the previous page. This process will repeat until all the records are displayed on each page. Sort of like what u see on forums. Is there a way to create new page dynamically with a link to it. Am I using the correct approach? Simple script will be greatly appreciated.
Thanx
getchoo 
|

March 12th, 2002, 05:20 AM
|
|
Contributing User
|
|
Join Date: Mar 2001
Posts: 36
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
Hi,
yes you're on the correct way. you need to use only "Start" paramater for your page. E.g. you're at the position starting with 20, so:
for previous:
<a href="page.jsp?start=10">previous</a>
for next:
<a href="page.jsp?start=30">next</a>
|

March 13th, 2002, 09:30 PM
|
|
Registered User
|
|
Join Date: Feb 2002
Posts: 20
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I'm still unclear how this works
Hi so this code allows me to create an unlimited unumber or pages to display all my records. Here is a portion of my code.
rs=statement.executeQuery("SELECT students.studentid, students.firstname, students.lastname, students.email," +
"btechpre.cisy1212, btechpre.cisy2311, btechpre.cisy2313, btechpre.cisy2314, btechpre.cisy2315," +
"credential.recdate, credential.qualified, credential.accepted, credential.applied FROM students, btechpre, credential " +
"WHERE students.studentid=credential.studentid AND credential.studentid=btechpre.studentid AND credential.recdate BETWEEN '"+startTime+"' AND '"+endTime+"' ");
//SELECT DATE_FORMAT(date,'%M %d, %Y') from data
while(rs.next())
{
String cisy1212=rs.getString("cisy1212");
String cisy2311=rs.getString("cisy2311");
String cisy2313=rs.getString("cisy2313");
String cisy2314=rs.getString("cisy2314");
String cisy2315=rs.getString("cisy2315");
%>
<tr bgcolor="#9999cc">
<td width="8%" height="18"><%= rs.getString("recdate")%></td>
<td width="10%" height="18"><%= rs.getString("studentid")%><input type="hidden" name="studentid" value="<%= rs.getString("studentid")%>"></td>
<td width="11%" height="18"><%=rs.getString("firstname")%> <%=rs.getString("lastname")%></td>
<td width="15%" height="18"><a href="mailto:<%=rs.getString("email")%>"><%=rs.getString("email")%></a></td>
<td width="13%" height="18">
<%
if((cisy1212!=null) || (cisy2311 !=null) ||(cisy2313!=null) ||(cisy2314!=null) ||(cisy2315!=null))
%>
<%=cisy1212%>,<%=cisy2311%>,<%=cisy2313%>,<%=cisy2314%>,<%=cisy2315%></td>
<td width="15%" height="18"><%=rs.getString("cisy1212")%>,<%=rs.getString("cisy2311")%>,<%=rs.getString("cisy2313")%>,<%=rs.getString("cisy2314")%>,<%=rs.getString("cisy2315")%></td>
<td width="6%" height="18"><%=rs.getString("qualified")%></td>
<td width="6%" height="18"><%=rs.getString("applied")%></td>
<td width="6%" height="18"><%=rs.getString("accepted")%></td>
<td width="6%" height="18">
<input style="BACKGROUND-IMAGE: url(file://C:\jakarta-tomcat-4\webapps\CISY2415\images\trash2.gif); WIDTH: 28px; HEIGHT: 36px; BACKGROUND-COLOR: #9999cc" type=submit name=delete size=14 onClick="document.btechreport.action='deletebtech.jsp'">
</td>
</tr>
<% } //end while()
//clean up
if(rs!=null) rs.close();
if(statement!=null) statement.close();
if(connection!=null) connection.close();
%>
</table>
</form>
so how do I use these tags in this code to display 10 records per page, where total number of records are unknown?
Thanx
getchoo
|

March 14th, 2002, 05:27 AM
|
|
Registered User
|
|
Join Date: Feb 2002
Posts: 20
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
heres revised code, but it still doesn't work.
What is wrong with the portion of the code that creates links to new page that contains the additional records "its commented on the bottom" and they mention an error with the Limit fcn in my mysql statement. Heres the code:
while(rs.next())
{
String cisy1212=rs.getString("cisy1212");
String cisy2311=rs.getString("cisy2311");
String cisy2313=rs.getString("cisy2313");
String cisy2314=rs.getString("cisy2314");
String cisy2315=rs.getString("cisy2315");
%>
<tr bgcolor="#9999cc">
<td width="8%" height="18"><%= rs.getString("recdate")%></td>
<td width="10%" height="18"><%= rs.getString("studentid")%><input type="hidden" name="studentid" value="<%= rs.getString("studentid")%>"></td>
<td width="11%" height="18"><%=rs.getString("firstname")%> <%=rs.getString("lastname")%></td>
<td width="15%" height="18"><a href="mailto:<%=rs.getString("email")%>"><%=rs.getString("email")%></a></td>
<td width="13%" height="18">
<%
if((cisy1212!=null) || (cisy2311 !=null) ||(cisy2313!=null) ||(cisy2314!=null) ||(cisy2315!=null))
%>
<%=cisy1212%>,<%=cisy2311%>,<%=cisy2313%>,<%=cisy2314%>,<%=cisy2315%></td>
<td width="15%" height="18"><%=rs.getString("cisy1212")%>,<%=rs.getString("cisy2311")%>,<%=rs.getString("cisy2313")%>,<%=rs.getString("cisy2314")%>,<%=rs.getString("cisy2315")%></td>
<td width="6%" height="18"><%=rs.getString("qualified")%></td>
<td width="6%" height="18"><%=rs.getString("applied")%></td>
<td width="6%" height="18"><%=rs.getString("accepted")%></td>
<td width="6%" height="18">
<input style="BACKGROUND-IMAGE: url(file://C:\jakarta-tomcat-4\webapps\CISY2415\images\trash2.gif); WIDTH: 28px; HEIGHT: 36px; BACKGROUND-COLOR: #9999cc" type=submit name=delete size=14 onClick="document.btechreport.action='deletebtech.jsp'">
</td>
</tr>
////////////////////////////////////////////////diplaying 10 records per page//////////////////////////////
//set number of rows per page
int maxrowPage = 10;
//initialize pagenumber to one(
int pageNum = 1;
int min = maxrowPage*(pageNum-1);
if(pageNum>1)
system.out.println("<A href=JSP_SELF?pageNum="+(pageNum-1)+">"Previous Page"</a>");
if(numProd>maxrowPage*(pageNum)
system.out.println("<A href=JSP_SELF?pageNum="+(pageNum+1)+">"Next Page"</a>");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
<% } //end while()
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|