You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sam Wun <sw...@gmail.com> on 2009/07/27 15:53:02 UTC

2-dimensional array.

Hi,

sorry this is not a Struts specific question, but I am working on a
JSP file that is related to the Struts.
I believe most of you guys are using JSP with struts, so I hope I can
get some help here.

I want to declare a String 2-dimensional array in JSP as follow:

String cat_sections[] = {"IP6-Calling-Card"};
//String cat_items_sections[][] = new String[1][];
String cat_items_sections[0][] = new String[results.size()];


But I got an error:

23:40:55,736 ERROR [IncludeTag:79] Current URL /web/guest/home
generates exception: Unable to compile class for JSP:

An error occurred at line: 90 in the jsp file:
/html/portlet/shopping/categories-main.jspf
Syntax error on token "0", delete this token
87:
88: String cat_sections[] = {"Main-Section"};
89: //String cat_items_sections[][] = new String[1][];
90: String cat_items_sections[0][] = new String[results.size()];
91:
92:

What I really want to do is,
cat_sections  has 3 items, illustrated as follow:

cat_sections - cat_items_section[0]
.....................- cat_items_section[1]
.....................- cat_items_section[2]

How to initiate and assign string into it?

your help is much appreciated.

Thanks
Sam

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: 2-dimensional array.

Posted by Pascal <pa...@voidmage.net>.
Maybe you wanted to do this?

String cat_sections[] = {"IP6-Calling-Card"};
String cat_items_sections[][] = { cat_sections };

I'm really not sure if you should use arrays here, though. Especially for
storing string constants you should really consider using enums.

Pascal

On Mon, 27 Jul 2009 23:53:02 +1000, Sam Wun <sw...@gmail.com> wrote:
> Hi,
> 
> sorry this is not a Struts specific question, but I am working on a
> JSP file that is related to the Struts.
> I believe most of you guys are using JSP with struts, so I hope I can
> get some help here.
> 
> I want to declare a String 2-dimensional array in JSP as follow:
> 
> String cat_sections[] = {"IP6-Calling-Card"};
> //String cat_items_sections[][] = new String[1][];
> String cat_items_sections[0][] = new String[results.size()];
> 
> 
> But I got an error:
> 
> 23:40:55,736 ERROR [IncludeTag:79] Current URL /web/guest/home
> generates exception: Unable to compile class for JSP:
> 
> An error occurred at line: 90 in the jsp file:
> /html/portlet/shopping/categories-main.jspf
> Syntax error on token "0", delete this token
> 87:
> 88: String cat_sections[] = {"Main-Section"};
> 89: //String cat_items_sections[][] = new String[1][];
> 90: String cat_items_sections[0][] = new String[results.size()];
> 91:
> 92:
> 
> What I really want to do is,
> cat_sections  has 3 items, illustrated as follow:
> 
> cat_sections - cat_items_section[0]
> .....................- cat_items_section[1]
> .....................- cat_items_section[2]
> 
> How to initiate and assign string into it?
> 
> your help is much appreciated.
> 
> Thanks
> Sam
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org