I am trying to disply the product column from the database into a table. I am able to add the items to the ArrayList But the items are not being displayed in the jsp. My action class is as follows:
The jsp is not printing the product name stored in the database. The jsp is as follows:
@Amandeep: That's not the preferred mechanism in Struts 2--there's no reason to set something to a JEE scope unless you have a specific requirement to do so.
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 837
posted
0
so what is the recommended approach to do this in struts 2?
Expose an action property, as the OP did in the second code snippet (but never filled it with values).
Prashant K. Singh
Greenhorn
Joined: May 11, 2009
Posts: 18
posted
0
Hi David,
I modified the action class and the jsp a bit and now I am able to print the output on the jsp.
But Hulloa there is a problem. Also every time I hit the refresh button, the output gets increased by one ie if i have bariton as output then it becomes barition bariton.
It's difficult to understand code's intent when there are ambiguities--for example, the action method creates a local variable called "productName", and the action has a property called "productName", and they're different types.
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 837
posted
0
David Newton wrote:Expose an action property, as the OP did in the second code snippet (but never filled it with values).
As i am a newbie to Struts 2. Just a question, in the previous code how Prashant is exposing the 'products' to the jsp.
Because inside the ActionSupport, we are not exposing it through any reference.