I don't see any problem here, please tell what error did you get. I can
successfully run this as a jsp:
<%@ page language="java" import="java.util.*,java.io.*" %>
<html>
<body>
<TABLE width="80%">
<tr bgcolor="lightgrey"><td>Title</td><td>Units</td></tr>
<%
ArrayList cart = new ArrayList();
String s1 = "s1";
String s2 = "s2";
String s3 = "s3";
String s4 = "s4";
cart.add(s1);
cart.add(s2);
cart.add(s3);
cart.add(s4);
Iterator iterator = cart.iterator();
while (iterator.hasNext())
{
%>
<tr>
<td>
<%String title=(String)iterator.next(); %>
<%=title%>
</td>
<td>
<input type="text" name="jumlah" value="1">
</td>
</tr>
<%
}
%>
</table>
</body>
</html>
#################################################################
> Hello all of Java Gurus.......
>
> I use iterator in my code
> and I have succeeded to display the iterator.next() in the browser
>
> but I want to pass it to next jsp, so I want to get the value of
> iterator.next and convert to String variable
>
> I try String title=(String)iterator.next(); but I found error .....
>
> I am new to Java so I still confused about these....
> Please help me to get value of iterator.next() to String variabel so I
can
> pass it as input with hidden type
> to next jsp.
>
> The codes is like these :
>
> <TABLE width="80%">
> <tr bgcolor="lightgrey"><td>Title</td><td>Units</td></tr>
> <%
> Iterator iterator = cart.iterator();
> while (iterator.hasNext())
> {
> %>
> <tr>
> <td>
> <%=iterator.next()%>
> </td>
> <td>
> <input type="text" name="jumlah" value="1">
> </td>
> </tr>
> <%
> }
> %>
> </table>
>
>