This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

using indexId

Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am using following JSP

Form bean is as follows

DemoVO has got setters and getters for empName and empId

When I hit my action, the form is displayed with all fields
populated from corresponding properties, but when i submit the
form I get following exception. Please clarify

javax.servlet.ServletException: BeanUtils.populate

root cause

Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You haven't indicated what scope is specified for your ActionForm in struts-config.xml. I suspect it's "request", and that would cause this problem. When a form bean is scoped to request, All the information you created to display the form is gone once the information is sent back to the browser. When the user submits the form, Struts instatiates a new ActionForm, but this one has no ArrayList of Employee objects. That's why you get the error.

The two possible solutions are:
  • Use session scope for the form bean. This is the easiest to implement, but you need to be careful how much data you store in the HTTPSession, as it can negatively impact your performance with many simultaneous users.
  • Keep the ActionForm at request scope and store only the total number of employees in the session. Then, in your ActionForm's reset() method, check to see if the ArrayList of employees is null. If it is, build an ArrayList with the correct number of employees. Then, when the user submits the form, the getters and setters will find the appropriate objects.

  • [*
      Bookmark Topic Watch Topic
    • New Topic