I have read that for static, I need to import the model.modelName which is what I did.
The jstl printed out the model.variables that meet the query in my servlet.
The problem is that inside the query also contains a List<String>actorNames which is part of the model.
I was able to print out the resultset via System.out.println but not able to get the same resultSet in the jstl.
The query is :
String sql1 = "select t.model_contact_no, model.zipcode, model.model_id, t2.actor_name FROM model t JOIN model_actor t2 ON t.model_id = t2.model_id where t.zipcode = ? And t2.actor_name = Any((?))"; PreparedStatement ps2 = connection.prepareStatement(sql1); ps2.setString(1, zipcode); for (int i = 0; i < actorNames.length; i++) { Array array = connection.createArrayOf("text", actors.toArray()); ps2.setArray(2, array); } ResultSet rs = ps2.executeQuery(); while (rs.next()) { t.setContactNo(rs.getString("model_contact_no")); t.setZipcode(rs.getString("zipcode")); t.setmodel_id(rs.getInt("model_id")); for (String s : actors) { if (actors.contains("actors_name")) { t.setActors(rs.getString("actors_name")); } myList.add(t); // I am also not sure about this part if it is correct since the query contains a list also request.setAttribute("list", myList); }
I do not know if I should create a separate request.setAttribute for the list<String>actorNames but since the List is part the model then it should not be separated right ?
Hope someone can tell me how to get this part done cos I can't find something anything similar in the web
<c:forEach items="${list} var="t" varStatus="status"> <tr> <td><c:set var="t" value="${model.model_id }" scope="request" /> <c:out value="${model.model_id}" /></td> <td>${t.zipcode} </td> <td>${t.contactNo} </td> <tr> <td><c:set var="t" value="${model.actorNames}" scope="request" /> <c:out value="${model.get(actors_name)}" /></td> // I need to get the element in the list<String> which meet the criteria above <c:out value="${actors_name[not sure what to put here]}"/> </tr> </c:forEach> </table>
I am just lost how to get the actorNames in my resultSet from the List<String>actorNames to be printed in this case.
Hope someone know the answer and let me know.
Thanks.