Fetch values from database into ArrayList then display on jsp page in struts2

This example shows how to fetch values from the database into ArrayList then displaying these values on the JSP page in Struts2 iterator tag.

See below example

ViewTeacher.java is the action class that is fetching the values from the MySQL database and the values are saving into the ArrayList “al”

 

ViewTeacherDatabase.java class contains the variables and getter & setter methods. If you do not create the getter and setter methods that values will not be displayed on the JSP page.

 

personalDetails.jsp is the JSP page where we are displaying values to the user.

 

struts.xml contains the mapping.