title: How to determine if resultset is empty?
body: <p>Good day!</p>
  
  <p>I am wondering how can I get the desired result in my <code>if-else statement</code> if i want to determine if my search is existing or not. I do various combinations as suggested in the previous questions related to this but still I cannot get what I want.</p>
  
  <p>Code 1: I cannot reach the else statement if my search is empty... </p>
  
  <pre><code>        if (resultSet!= null) {
              while (resultSet.next()) {   //MULTIPLE VALUE SEARCH
                  Product product = new Product();
                  product.setProductId(resultSet.getInt("productId"));
                  product.setProductName(resultSet.getString("productName"));
                  productList.add(product);
              }
              request.setAttribute("productList", productList);
              RequestDispatcher rd = request.getRequestDispatcher("adminViewSearch.jsp");
              rd.forward(request, response);
          } else {
              request.setAttribute("message", "Search Failed"):
              RequestDispatcher rd = request.getRequestDispatcher("adminViewSearch.jsp");
              rd.forward(request, response);
          }
  </code></pre>
  
  <p>Code 2: I cannot also reach the else statement where values searched should be displayed...</p>
  
  <pre><code>        if (!resultSet.next()) {
               .... Search Failed Message    
          } else { 
               while(result.next()){.....
          }
  </code></pre>
  
  <p>Code 3: Same result as Case 1:</p>
  
  <pre><code>        if (resultSet.wasNull()) {
               .... Search Failed Message    
          } else { 
               while(result.next()){.....
          }
  </code></pre>
  
  <p>I tried other combinations and still I cannot achieve the result I desired which is as follows: 
  When the user search a value, if the resultset is null, an error message will appear, else if the search is not null, 1 or multiple searches will be displayed.</p>
  
  <p>Kindly give me an alternative on how to this the easier way because it seems like I am doing it wrong. </p>
  
  <p>Thank you in advance..</p>