• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ArrayI ndex OutOfBoundsException when page refresh

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an action which uses the following form-bean below. All works fine when the page is first displayed. In addition to user submit. For example AccessRequest[] can initially contain a list of requests lets say 5. The user can then modify request by updating info. For example he may update 2 of the 5. Then hit submit. Once requests are modified they are removed from the list. The page is refreshed and there will only be 3 requests. All works fine. However if user hits refresh on the browser I get the error below. Its very strange if I simply update one request it works fine. If user updates more than one it throws error when refresh is hit. I have placed break points throughout and it gets to the reset() method in MyDynaActionForm which obtains the correct array size. It then exits reset() and error is thrown. It never reaches the action. Thank you all for your time.

I have the following form in struts-config



I get the following error

ArrayIndexOutOfBoundsException: 0 at reflect.Array.get(Native Method)at org...DynaActionForm.get(DynaActionForm.java:250)
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing that could cause this would be specifying redirect="true" on the forward for action that prepares the display of the current JSP. In this case, a refresh would cause the JSP to be displayed without the preparatory Action being called, which is not what you want.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No I don't call redirect="true". I have the following. /setupForm is initially called to display the data. setuppage.jsp will call /processForm.

 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe changing the following will fix the problem:

This way when the user refreshes the page, the URL is always setupForm.do.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Merrill. That solved the problem. That way I also got rid of my code which saved the token. To avoid duplicate submit i.e. saveToken(request); ect. Thanks again
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic