This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass request Attribute to Action in Struts 2

 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody..

How to pass Request Attribute to Action..

I am having problem with it.
can anybody help me please?

Thanks
Raza
 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its pretty difficult do help you if you dont provide any more information. May tell us exactly what the problem is. Some code from your Action and JSP youre having problems with would be very helpful.
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply.

I am having a Jsp where i am getting filtered List of Banks.

and setting that List to request.

AS

request.setAttribute("filterList",bankList);

and redirecting to JSP .

But Again calling the Same Action on different method List to get that List from request but its NUll.


my Action is....





 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Action mapping is..

 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somehow I think that that is not the Struts2 way of doing things.


Firstly why are you putting attributes directly into the attibutes map of the ServletRequest?
if you have a field "bankList" with public property accessors you can just say and call it directly from your jsp using struts or jstl tags.

secondly, have you made sure that "bank" really is != null ? is the method filter being called correctly?

In what way are you accessing bankList from your jsp?

In Struts2 under "normal" circumstances its not necessary to do "low-level" operations like putting attributes / parameters into the ServletRequest. The framework does this for you.

 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks..

but in filter method the list i am getting is filtered on some criteria ...and i want the same list on list() method.
as in list() method either All the banks will be called or if there is filtered List on Request , will be called.

Is there any possible solution to get Request Attribute on list() method?

Thanks..
Raza.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic