Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 jsp Error.

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Im facing an error while trying to run my jsp .Below , is the stacktrace of my error.

Mar 18, 2011 2:42:40 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'listbean.dt_oid': The requested list key 'dtList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:231)
at org.apache.struts2.components.Component.findValue(Component.java:293)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:99)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:780)
at org.apache.struts2.components.UIBean.end(UIBean.java:481)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
at org.apache.jsp.jsp.interface_jsp._jspx_meth_s_005fselect_005f0(interface_jsp.java:376)
at org.apache.jsp.jsp.interface_jsp._jspx_meth_s_005fform_005f0(interface_jsp.java:265)
at org.apache.jsp.jsp.interface_jsp._jspService(interface_jsp.java:165).

I think its linked to this tag
.
Please suggest how I could overcome it..
Thanks.
 
Rishi Kanth
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dtList" is not of type ArrayList or List in the Java class. Check the action class which is passing this parameter to the JSP file.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rishi ,
This is my action class below, and it does contain references to dtList.


So what Am I doing wrong here? Please help
 
sri ramvaithiyanathan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this Link.

Initialize your arraylist ie dtList inside your action class and add the values to arraylist.
Before moving to jsp page,check the size of the arraylist inside your action class.

Hope it will clear your doubt.
waiting for your reply
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sri ramvaithiyanathan wrote:check this Link.
Hope it will clear your doubt.
waiting for your reply

Hi ,
I did check that link and think Ive already done whats been mentioned in the link.IVe used getters and setters of the bean list array dtList in the action class and my select tag in the jsp also fetches that particular array list an populates into the name attribute . So please advise what Im missing here > Thanks.
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vic,

This error might occur if your page is having validation error and you are not navigation your Error to the most appropriate JSP.
Validation errors are encountered before calling
For example ..define result name in your struts.xml as 'ERROR' or 'INPUT' and corresponding jsp for validation error.

thanks and Regards
Raza
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raza ,
Im not using much of validation here . im just using the struts.xml for redirecting my pages.Ive attached a copy of the same .
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vic,

Look at your code.might be, your method is getting exception and in the catch you assign Error to result parameter.
That might causing the page to navigate to Error which is not defined in struts.xml

Thanks and regards
Mohd Raza.
 
sri ramvaithiyanathan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have declared your arralist as

and inside action class you used as


what I am saying is initialize inside your action class like this

I am not sure whether it will work but give one try.

Regards,
Sriram.V
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic