Hi all,

I am having a little problem in taking a list of search results that I generate from a JSP page, and when selecting the checkbox I want to view a particular resources result for, displays the wrong information. I can get the first result to be able to display the correct information on a particular resource, but when I want to view the second or third result, I get the first result resource information instead. I am not very good at explaining the situation, so I shall provide an example:

I search for Harry Potter books, this is sent to the server to obtain the search results and generates a page with the results. On the results page I have checkboxes beside each search result. I check the first and click on "view information", this generates a new page from the server, with all the details of the first search result - This part is fine.

However, if I perform my search again, and check the second search result, and generate a new page with the second search result's details, it just gives me the first results detailed information, and not the second result's detailed information - This part is the problem, and the same applies to the other search results.

So my question is why is it displaying the detailed information for the first search result, when I ask for the second search result's detailed information?
Here is my code:

Java Code:
<%@ page language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Advanced Search Results Page</title>
</head>
<body>
<h3>Advanced Search Results Page</h3>
<h3><font color="red">
         <% String e = (String) session.getAttribute( "error" );
				if ( e != null )
                { %>
				<font color="red">
				<% out.print( e );
				} %>
   </font></h3>
   <p>
      Your Advanced Search results are displayed below. If you wish to view full details of a particular resource
	  then please check the box beside the resource and click on "View Full Details of Library Resource" button.
	  Please note that only <b>one</b> checkbox selection can be made.
   </p>
   <p>
<form action="getFullInfo.jsp" method="post">
<table>
   <tr>
      <td></td>
      <td><b>Author</b></td>
	  <td></td>
	  <td><b>Title</b></td>
	  <td></td>
	  <td><b>Edition</b></td>
	  <td></td>
	  <td><b>Publisher</b></td>
	  <td></td>
	  <td><b>ISBN</b></td>
	  <td></td>
	  <td><b>Avaliability</b></td>
   </tr>
   <c:forEach var="list" items="${list}">
   <tr>
      <td><input type="checkbox" name="cb1" /></td>
      <td>${list.author}</td>
	  <td></td>
	  <td>${list.title}<input type="hidden" name="hidden" value="${list.title}" /></td>
	  <td></td>
	  <td>${list.edition}</td>
	  <td></td>
	  <td>${list.publisher}</td>
	  <td></td>
	  <td>${list.isbn}</td>
	  <td></td>
	  <td>${list.avaliability}</td>
   </tr>
   </c:forEach>
</table>
<input type="submit" value="View Full Details of Library Resource">
</form>
</p>
</body>
</html>
Java Code:
import java.io.* ; 
import java.util.*;
import javax.servlet.* ;
import javax.servlet.http.* ;
import java.sql.*;
import beans.*;

public class GetResourceInfo extends HttpServlet
{
	Connection conn; // variable to connect to the database
    Statement stmt;  // variable to execute SQL statements
	
	public void init( ) throws ServletException
	{
		try
		{
			Class.forName( "com.mysql.jdbc.Driver" ).newInstance(); // load the JDBC mysql driver
            
		} 
		catch (Exception ex) 
		{ 
			System.out.println( "Exception is: " + ex.toString( ));
		}
	}
	
	public void doPost( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException
	{
		try 
		{
			// connect to the database on the server called w1172769_0 with mysql username and password
			conn = DriverManager.getConnection( "jdbc:mysql://localhost/" + "dbtwo?user=root&password=hotfuzzbun") ;
                                            
			stmt = conn.createStatement( );
		}
		catch (SQLException ex) 
		{ 
			System.out.println("SQLException: " + ex.getMessage());
		}
		
		// extract the fields from the advancedSearch.jsp webpage
		String strHidden = request.getParameter( "hidden" );
		
		boolean bValid = true;
		
		SearchBean searchBean = new SearchBean();
		
		HttpSession session = request.getSession(  ) ;
		String strError = ( String ) session.getAttribute( "error" ) ;
		
		try
			{
				int count = 0 ;
				String strQuery = "select * from library_catalogue where title = '" + strHidden + "'" ;
				ResultSet rs = stmt.executeQuery( strQuery ) ;
				
				while ( rs.next( ) )
				{
					count++ ;
					searchBean.setAuthor( rs.getString( "author" ) ) ;
					searchBean.setTitle( rs.getString( "title" ) ) ;
					searchBean.setDescription( rs.getString( "description" ) ) ;
					searchBean.setEdition( rs.getString( "edition" ) ) ;
					searchBean.setPublisher( rs.getString( "publisher" ) ) ;
					searchBean.setIsbn( rs.getString( "isbn" ) ) ;
					searchBean.setAvaliability( rs.getString( "avaliability" ) ) ;
					searchBean.setMaterialType( rs.getString( "material_type" ) ) ;
					searchBean.setUrl( rs.getString( "url" ) ) ;
				}
				
				if ( count != 1 )
				{
					bValid = false ;
					strError = "No details can be found" ;
				}
				
				if ( stmt != null )
				{
					stmt.close( ) ;
				}
				if ( conn != null )
				{
					conn.close( ) ;
				}
			}
			catch ( SQLException ex )
			{
				System.out.println( "SQLException: " + ex.getMessage( ) ) ;
			}
			
			if ( bValid )
		    {
			   session.setAttribute( "searchBean", searchBean ) ;
			
			   RequestDispatcher dispatcher = getServletContext( ).getRequestDispatcher( "/libraryResourceDescription.jsp" ) ;
			
			   dispatcher.forward( request, response ) ;
		    }
		    else
		    {
			   session.setAttribute( "error", strError ) ;
			
			   RequestDispatcher dispatcher = getServletContext( ).getRequestDispatcher( "/advancedSearchResults.jsp" ) ;
			
			   dispatcher.forward( request, response ) ;
		    }
			
		}
		
	public void doGet( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException
	{
		doPost( request, response ) ;
	}
}
Java Code:
<%@ page language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Library Resource Description Page</title>
</head>
<jsp:useBean id="searchBean" class="beans.SearchBean" scope="session" />
<body>
<h3>Library Resource Full Description Page</h3>
<h3><font color="red">
         <% String e = (String) session.getAttribute( "error" );
				if ( e != null )
                { %>
				<font color="red">
				<% out.print( e );
				} %>
   </font></h3>
<table style="width:100%;">
   <tr>
      <td><a href="index.jsp"><img src="img/home.jpg" alt="home" align="left" border="0"></a></td>
      <td><b>Author:</b></td>
      <td><jsp:getProperty name="searchBean" property="author" /></td>
      <td>( ENTER CODE FOR IMAGE HERE )</td>
   </tr>
   <tr>
      <td><a href="userActivities.jsp"><img src="img/useractivities.jpg" alt="home" align="left" border="0"></a></td>
      <td><b>Title:</b></td>
      <td><jsp:getProperty name="searchBean" property="title" /></td>
	  <td></td>
   </tr>
   <tr>
      <td><a href="quickSearch.jsp"><img src="img/quicksearch.jpg" alt="home" align="left" border="0"></a></td>
	  <td><b>Description:</b></td>
      <td><jsp:getProperty name="searchBean" property="description" /></td>
      <td></td>
   </tr>
   <tr>
      <td><a href="index.jsp"><img src="img/backtosearch.jpg" alt="home" align="left" border="0"></a></td>
      <td><b>Edition:</b></td>
      <td><jsp:getProperty name="searchBean" property="edition" /></td>
      <td></td>
   </tr>
   <tr>
      <td><a href="logout.jsp"><img src="img/logout.jpg" alt="home" align="left" border="0"></a></td>
      <td><b>ISBN:</b></td>
      <td><jsp:getProperty name="searchBean" property="isbn" /></td>
      <td></td>
   </tr>
   <tr>
      <td></td>
      <td></td>
      <td></td>
   </tr>
   <tr>
      <td></td>
      <td><input id="Button1" type="button" value="RESERVE THIS RESOURCE" /></td>
      <td></td>
   </tr>
</table>
</body>
</html>
I hope you can help me.