Результат в JSP

Мне нужна помощь с переадресацией набора результатов (rs) в jsp. Я реализовал структуру MVC в JAVA (примечание: я новичок в этом). Логический поток для того же ниже:

basic form : Where user enters his choice . On submission the flow get directed to a servlet. From servlet the flow goes to a Java file where the data base retrieval and other logic is taken care of. Then the result is send back to the servlet . Servlet forwards the result to a JSP for display.

Сервлет:

package com.example.web;
import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class CoffeeSelect extends HttpServlet {

  public void doPost( HttpServletRequest request, 
                      HttpServletResponse response) 
                      throws IOException, ServletException {
            String c = request.getParameter("type");
            CoffeeExpert ce = new CoffeeExpert();
            List result = ce.getTypes(c);
            request.setAttribute("styles", result);
            RequestDispatcher view = request.getRequestDispatcher("result.jsp");
            view.forward(request, response); 
          }
        }

Java-файл:

    package com.example.model;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.*;

    public class CoffeeExpert {
       public List<Types> getTypes(String test) {

          ResultSet rs = null;
         List<Types> list = new ArrayList();
         String Name = "na";
         String PCANo = "NotFound";
         String IP = "NotFound";
         Types type=new Types(); 
         if (test.equals("ABC")) {
         try{
         Connection con = getConnection();
         String Query = "select * from Table1";
         // System.out.println(Query);

          rs = con.createStatement().executeQuery(Query);

                 while (rs.next()) {
                     type.setName(rs.getString(1));
                     type.setPCANo(rs.getString(2));
                     type.setIP(rs.getString(3));
                   System.out.println(Name+"  "+PCANo+"  "+IP);
                   list.add(type);
                   }
                   rs.close();
                   con.close();

               }catch (SQLException e) {
                System.out.println("SQLException");
                e.printStackTrace();
             }
         }
         else {
            System.out.println("Didn't find any data");
         }
         return(list);
       }

       public static Connection getConnection() {

             Connection con = null;
             String Res = "na";
             String BusinessUnit = "NotFound";
             ResultSet rs = null;
             try {
                 // Load the JDBC driver
                String driverName = "oracle.jdbc.driver.OracleDriver";

                // String driverName = "oracle.jdbc.OracleDriver";
                 Class.forName(driverName);
                 // Create a connection to the database
                 //Dev
                 String serverName = "xx.xx.xx.xx";
                 String portNumber = "1521";
                 String sid = "SSSS";
                 String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
                 String username = "SSSSS";
                 String password = "password";
                 con = DriverManager.getConnection(url, username, password);
                  return con;
                  } catch (ClassNotFoundException e) {
                System.out.println("ClassNotFoundException");
                e.printStackTrace();
             } catch (SQLException e) {
                e.printStackTrace();
            }
            return con; 
          }
     }

Как предлагается в решении ниже, Другой модельный класс

    package com.example.model;

    public class Types {
        private String Name;  
        private String PCANo;
        private String IP; 
        //constructors   //getter-setters 
        public String setName(String Name){     
            return this.Name = Name;  
         }   
         public String getName() { 
            return this.Name; 
         }
         public String setPCANo(String PCANo) { 
            return this.PCANo = PCANo;  
         }  
         public String getPCANo() {  
            return this.PCANo;   
         }  
         public String setIP(String IP) { 
                return this.IP = IP;  
             }  
             public String getIP() {  
                return this.IP;   
             }  
    } 

Конечный файл отображения JSP

<%@ page import="java.util.*" %>
<%@ page import="com.example.model.Types" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<html>
<body>
<h1 align="center">Final Data JSP View</h1>
<p>

<%

List<Types> styles = (List<Types>) request.getAttribute("styles");
if(styles!=null){
    for(Types type: styles){  
        out.println("<br/>" + type.getName() + " " + type.getPCANo()+ " " + type.getIP());  
        }  
    } 
%>
            </body>
</html>

Результаты выбирают только последнюю строку для всех отображаемых строк, то есть таблица базы данных имеет три строки, последняя строка отображается 3 раза.

ABC PCA100 XXX.1.0.0
ABC PCA100 XXX.1.0.0
ABC PCA100 XXX.1.0.0

Ответы на вопрос(1)

Ваш ответ на вопрос