tags:

views:

191

answers:

1

Hi all,

we can set attributes in servlet and we can get those values in jsp by accessing get attribute. 

Like that do we have anything to access values in jsp. For Example, DynaActionForm home = (DynaActionForm) form; String age = (String)home.get("age"); I want to access this age in jsp.

Please help me to solve this. Thanks

A: 

Are you asking if you can access DynaActionForm values directly within the Struts View (jsp) component?

You could try setting the DynaActionForm as a request attribute in your Struts Action:

DynaActionForm myForm = (DynaActionForm) form;
request.setAttribute("myForm", myForm);

Then in your JSP page import DynaActionForm and do something like:

DynaActionForm myForm = (DynaActionForm) request.getAttribute("myForm");
String age = (String) myForm.get("var");

But it would be much better to just access the value you needed within the Struts Action and just set that value onto the request or session.

Art Peterson