Some posts used to return to a page:
/ ** * Get the top-level threads under the given category from start index * * @param category - The category * @param startIndex - The start index for retrieveing the records * @param length - The number of records to be tretieved * @return Collection - A collection of threads under the given category * / public Collection findByCategory (final int category, final int startIndex, final int endIndex) throws SQLException, CategoryNotFoundException {final Connection conn = getConnection (); final ArrayList result = new ArrayList ( ); final PreparedStatement stat = conn.prepareStatement ( "select * from threads where category_id =" category "order by last_update DESC"); final ResultSet resultSet = stat.executeQuery (); if (resultSet.absolute (startIndex)) { Do {result.add (new thread (resultSet.ge) TSTRING ("ID"), ResultSet.getstring ("Title"), ResultSet.getstring ("Content"), ResultSet.GetString ("Author"), ResultSet.Getlong ("Last_update")} while (ResultSet.Next) ) && (resultSet.Getrow () <= endindex);} stat.close (); conn.close (); returnrate;}
Thread indicates a post Category is the forum number resultset.absolute (startIndex) is used to locate the post result stored in ArrayList.
Then use the While loop in the JSP to turn the contents of the Collection one output.