By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,737 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,737 IT Pros & Developers. It's quick & easy.

Setting an array in JSP with resultset data from a javabean

P: n/a
Hi all-
I am having a little trouble storing resultset data from a javabean
into an array located in a JSP page.
Any other approaches, advice or links to information would be
appreciated.
Thanks in advance.
Alex O-

If have tried this but I get a tomcat error stating that it expected
String instead of String[].

|--BEGIN JSP CODE --|
<% Resultset rs = FieldJB.fieldResults(); %>
<% String [] stringarray = new String [5]; %>

<% for (int floop = 0; floop<= 5; floop++)
{
while (rs.next())
{
stringarray[floop] = rs.getString("table.field");
}
floop++;
}
%>
|-- END JSP CODE --|
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
G'Day,

Mate, I would do the following:

<% int ARRAYLEN = 5;
<% Resultset rs = FieldJB.fieldResults(); %>
<% String [] stringarray = new String [ARRAYLEN]; %>
<%
int floop = 0;
while( rs.next() && floop < stringarray.length ) {
stringarray[floop++] = rs.getString("table.field");
}
%>

Warm regards,

Eki
"Alex" <al********@netzero.com> wrote in message
news:78*************************@posting.google.co m...
Hi all-
I am having a little trouble storing resultset data from a javabean
into an array located in a JSP page.
Any other approaches, advice or links to information would be
appreciated.
Thanks in advance.
Alex O-

If have tried this but I get a tomcat error stating that it expected
String instead of String[].

|--BEGIN JSP CODE --|
<% Resultset rs = FieldJB.fieldResults(); %>
<% String [] stringarray = new String [5]; %>

<% for (int floop = 0; floop<= 5; floop++)
{
while (rs.next())
{
stringarray[floop] = rs.getString("table.field");
}
floop++;
}
%>
|-- END JSP CODE --|

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.