Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts-JSP: Using for loop to retrieve Message resources that are in an array

 
George Kandalepas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm a struts newbie...

I am trying to create a JSP used as an exam page. There are 20 different exams, all with th same format (15 multiple choice questions, a-d)

I am putting the questions in a resource.properties file but I am having a hard time referencing the resource file. The following is a for loop I am trying to use to retrieve the messages but I cannot cacatenate the index to the bean:message:

<% for(int index=0;index<5;index++){ %>
<td><html:radio property="testQuest01" value="a">
<bean:message key="app.quest1.option[+index+]" /></html:radio></td>
<% } %>

ApplicationResources.properties example:

app.quest1.option[0]=a. The length...
app.quest1.option[1]=b. Number of ...
app.quest1.option[2]=c. Minimum of ...
app.quest1.option[3]=d. Maximum ...
app.quest1.option[4]=e. b & c

Does anyone have any suggestions,

I would appreciate any help.

Also if I were to use <c:forEach...> or <logic:iterate> how would the syntax go?

Thank you.

GK

Sorry about that!
[ August 18, 2004: Message edited by: George Kandalepas ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George, let me move this thread to the Web Applications Framework forum which handles questions about Struts.

Thanks

Mark
 
George Kandalepas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by George Kandalepas:
Hello, I'm a struts newbie...

I am trying to create a JSP used as an exam page. There are 20 different exams, all with th same format (15 multiple choice questions, a-d)

I am putting the questions in a resource.properties file but I am having a hard time referencing the resource file. The following is a for loop I am trying to use to retrieve the messages but I cannot cacatenate the index to the bean:message:

<% for(int index=0;index<5;index++){ %>
<td><html:radio property="testQuest01" value="a">
<bean:message key="app.quest1.option[+index+]" /></html:radio></td>
<% } %>

ApplicationResources.properties example:

app.quest1.option[0]=a. The length...
app.quest1.option[1]=b. Number of ...
app.quest1.option[2]=c. Minimum of ...
app.quest1.option[3]=d. Maximum ...
app.quest1.option[4]=e. b & c

Does anyone have any suggestions,

I would appreciate any help.

Also if I were to use <c:forEach...> or <logic:iterate> how would the syntax go?

Thank you.

GK

Sorry about that!

[ August 18, 2004: Message edited by: George Kandalepas ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic