• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display Results into Table

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to display result depending on a selection from a form. The page has 4 form elements and a submit button and a table with the results directly below.

I am listing the values as follows:


<%
List searchList = searchData.getSearchList();
Iterator searchListIterator = searchList.iterator();


while (searchListIterator.hasNext() ) {
search = (SearchBean ) searchListIterator.next();
%>

<tr>
<td height="22"><%= search.getArtistName() %></td>
<td><%= search.getAlbumName() %></td>
<td><%= search.getGenreName() %></td>
<td><%= search.getParentalName() %></td>
<td><%= search.getLocationName() %></td>
</tr>

<%
}
%>

</table>
<p> </p>
<p> </p>
<p>
<% // continue scriptlet
} // end if
else {
searchData.searchCD( artist, genre, location, parental, album );

%>
<%-- end scriptlet to insert jsp:forward action --%>
<%-- forward to display guest book contents --%>
</p>

<% // continue scriptlet

} // end else

%>


I need to list the values from the searchData method. I want to display all the results in the searchList when a user first comes to the page and then when the user click submit, I want the page to display only the criteria listed posted from the form. My SQL Statement is as follows:

public void searchCD(
ArtistBean artist,
GenreBean genre,
LocationBean location,
ParentalBean parental,
AlbumBean album)
throws SQLException {
String sqlStmt = "";
if (artist.getArtistID() == "All")
sqlStmt = sqlStmt + "WHERE CD.ARTIST_ID = ARTIST.ARTIST_ID AND ";
else
sqlStmt =
sqlStmt
+ "WHERE CD.ARTIST_ID = "
+ artist.getArtistID()
+ " AND ARTIST.ARTIST_ID = "
+ artist.getArtistID()
+ " AND ";

if (genre.getGenreID() == "All")
sqlStmt = sqlStmt + "CD.GENRE_ID = GENRE.GENRE_ID AND ";
else
sqlStmt =
sqlStmt
+ "CD.GENRE_ID = "
+ genre.getGenreID()
+ " AND GENRE.GENRE_ID = "
+ genre.getGenreID()
+ " AND ";

if (parental.getParentalID() == "All")
sqlStmt = sqlStmt + "CD.ADVISORY_ID = ADVISORY.ADVISORY_ID AND ";
else
sqlStmt =
sqlStmt
+ "CD.ADVISORY_ID = "
+ parental.getParentalID()
+ " AND ADVISORY.ADVISORY_ID = "
+ parental.getParentalID()
+ " AND ";

if (location.getLocationID() == "All")
sqlStmt =
sqlStmt
+ "CD.LOCATION_ID = LOCATION.LOCATION_ID ORDER BY ARTIST.ARTIST_NAME ";
else
sqlStmt =
sqlStmt
+ "CD.LOCATION_ID = "
+ location.getLocationID()
+ " AND LOCATION.LOCATION_ID = "
+ location.getLocationID()
+ " ORDER BY ARTIST.ARTIST_NAME ";

statement.executeUpdate(
"SELECT * FROM CD, ARTIST, GENRE, ADVISORY, LOCATION " + sqlStmt);

Please let me know if you have any suggestions.. Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic