Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help wanted please!!  RSS feed

Donna Harrington
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
Just wondering would anybody know how do I click on any hyperlink (which is records from the database displayed as hyperlink) that i'm brought to the desired page. Here is my code, where database returns all the records to the JSP page as hyperlinks. But what happens at the moment is, whichever link in the table is clicked, u are brought to the same page ('ProductList.jsp'), while i want different pages for different links. I hope this isnt too confusing! Thank you!
<TABLE align ="centre" border= "5">
<% for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
<TD><FONT size=5 FACE="Arial"></FONT>
<%= rs.getMetaData().getColumnName(i) %>
<% } %>
<% while (
{ %>
<TR BGCOLOR="#ffff00">
<% for(int i=1;i<=rs.getMetaData().getColumnCount();i++){ %>
<%if (i==3){ %>
<TD><a href="ProductList.jsp?id=<%= rs.getString("categoryId")%>"><%=rs.getString("name")%><%=rs.getString("description") %></a></td>
<% } else { %>
<TD><%= new String(rs.getString(i)) %></TD>
<% }
<% } %>

Suma K Gowda
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to link to a different jsps, then
1) Have a seperate column in the database to store jsp page names. Then along with other records retrive the jsp name.
<a href=<%=getString("jspname")%>?yourquerystring>
or at the page scope declare a string to store the jsp name, if there isn't too many jsps for different links. have a switch statement and according to the different case hard code the jsp names and return that to your href.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!