How To Assign Arraylist To Select Option In Jsp October 11, 2024 Post a Comment I have the list: ArrayList list = new ArrayList(); I write this list select option: select&lSolution 1: It's not recommended to use java code inside jsp. You should try to avoid it.The approach that needs to be followed in your case, is to first set the Arraylist as an attribute in the servlet that is calling the jsp page.Servlet CodeArrayListdatabaseArrayList=newArrayList(); ... request.setAttribute("databaseList", databaseArrayList); CopyThen, in the JSP code, use jstl to iterate through the values of the list to populate the select options.JSP Code<select name="database1"> <c:forEach items="${databaseList}" var="databaseValue"> <option value="${databaseValue}"> ${databaseValue} </option> </c:forEach> </select> CopyI've written an article for looping over HashMap and ArrayList in JSPSolution 2: I guess You are doing great, just change your code like:- <option value="<%out.print(Field); %>"></option> Hope this works Share Post a Comment for "How To Assign Arraylist To Select Option In Jsp"