This is a not related to my project code , but a question came to my mind
This is my jsp page where there is a combination of Struts2 tags and scriptlet
which isn’t working and if i keep only the Scriptlet code its woring fine
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import = "java.util.ArrayList" %>
<%@ page import = "java.util.List" %>
<html>
<head>
<title>Struts 2 </title>
</head>
<body>
<s:form action="login" method="POST" >
<tr>
<td colspan="2">
Login
</td>
</tr>
<%
List list = (ArrayList)request.getAttribute("datareq");
for(int i=0;i<list.size();i++)
{
System.out.println(list.get(i).toString());
}
%>
<s:submit value="Login" align="center"/>
</s:form>
</body>
</html>
my question is , cant we have both of them ??
Of course you can use the two together. I assume this is just to demonstrate the point because there are better ways to iterate (the struts iterate tag and the jstl forEach tags), also it is extremely rare to scriptlets these days, that said…
What you have provided works perfectly, but you should be aware…