Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Declaring String array in JSP  RSS feed

 
Chris Goh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<% String buffer[]=new String[13];
buffer[0]="test";
%>

<%=buffer[0]%>
can i do this?
It can't seems to work. The console kept give me an undeclared variable error.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In
<% String buffer[]=new String[13];
buffer[0]="test";
%>
the variable buffer is available locally and thus is not available in other scriplets. You need to declare the variable buffer using the
<%! declaration(s) %>
if you want to use buffer in other scriplets.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!