• Post Reply Bookmark Topic Watch Topic
  • New Topic

array in jsp

 
rupendra sahu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look in follwoing code, I am surpriced that array is not giving same answer for same loop.
// This part is getting parameter from other page and parsing into array ss.
StringTokenizer st = new StringTokenizer(hidiValue,",");

int ntoken;
int x=0;
int y=0;
while(st.hasMoreTokens()){
ntoken = st.countTokens();
if(x>2)
x=0;
if(y>2)
y=0;
ss[x][y] = st.nextToken(); %>


<%= ss[x][y]+"."+x+"."+y+"|" %>
<% x++;
y++;
%>

<% } }%>


<%} else {



} %>
// This part is to display the parsed result.
But to my surprise it gives different result.
<table border=1>

<%
int d=0;
int e=0;
for(d=0;d<3;d++) { %>
<tr>
<%
for(e=0;e<3;e++) { %>
<td>
<%= ss[d][e] %>
</td>
<%} %>
</tr>

<%}%>
</table>
------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!