File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem with IndexId attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with IndexId attribute" Watch "Problem with IndexId attribute" New topic

Problem with IndexId attribute

Vivek Choudhary

Joined: Jan 30, 2008
Posts: 4
Hi All..
I am new to struts and having a problem with IndexId attribute of iterate..
I have to edit the marks of courses of some students..
so first i have to display the marks and courses and then submit new marks..

----my jsp code(editMarks.jsp)--------

---------my Form Bean(

------------my Action Form(


I m getting an error "javax.servlet.ServletException: Exception thrown by getter for property course[0] of bean org.apache.struts.taglib.html.BEAN"

can anyone help me..
thanks in advance..
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 471

Hello Vivek,

You have some mistakes in your JSP. Let's just explain the logic:iterate first. First of all, the id attribute is a name given to the current element of the collection you are iterating on. This means that if you are iterating on a collection named collection and you put the value of the id attribute as element, then at the first iteration, element will have the value of collection[0], and so on.

The indexId attribute is just a name of a variable that will act as a counter variable so that you can use it in your JSP for several reasons (for example if you are displaying results in rows, you can give a style to even rows, and another to odd ones), but not to get the element from the collection, since it's already there.

Now, your collection is in the action form, and that's a little tricky. Here, the name attribute should be the name of your form (I guess as defined in the struts config file), and the property attribute should be the name of the collection property in that form. I usually prefer putting my collections in a request attribute rather than in the form class.

I hope this helps. Please try and tell me the result

Visit my blog:
I agree. Here's the link:
subject: Problem with IndexId attribute
It's not a secret anymore!