This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass object from jsp to action class in struts???

 
Mahanth Kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to pass an object(ArrayList) to an action class...

<html-el:hidden property = "arrayListOfEmpData" value = "${element.arrayList_Of_EmpData}"/>

<a href = "ExcelD.do?arrayList_Of_EmpData=arrayListOfEmpData">Report in Excel</a>

i tried the above but it throws the following exception...


exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1656)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1551)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1580)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:919)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot create a single hidden field to pass an entire ArrayList of values. If you have an ArrayList of Strings, you can pass them by creating a hidden field for each element of the List and using indexed properties. See question 6 of the FAQ for more details on indexed properties.

A far easier way to do it would be just to put the ArrayList in session scope.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic