wood burning stoves 2.0*
The moose likes JSP and the fly likes Display Results into Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Display Results into Table" Watch "Display Results into Table" New topic
Author

Display Results into Table

Matt Hoffman
Ranch Hand

Joined: Jun 03, 2004
Posts: 83
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Results into Table
 
Similar Threads
how to fetch the value of the checkbox in jsp?
How to retrive data two times from database in sinble jsp page.
javascript "object expected " error
layout and multibrowser hell
Search and Result Page