tags:

views:

439

answers:

2

I am working on a struts2 application. I have an auto generated field in my action class and I am getting its value in a String variable. Now, after returing "SUCCESS" by this action class, struts.xml is routed to open a jsp page (say abc.jsp). I want to get that String variable (having auto generated field value) at my jsp page without creating object of action class in my jsp. Please suggest.

+1  A: 

The action class is always created in struts2. You will still have the same instance present when the abc.jsp renders, so you do not have to create a new instance of the action class. This is fairly central to how struts2 works.

So using regular ognl you can access all getters/setters in the controller when the jsp executes (unless you have used a ServletRedirectResult, which is slightly different)

krosenvold
+1  A: 

To add to krosenvold's answer properties from your action class are fetched using the s:property tag, so if you have a getter named getSpecialString you'd fetch it like this :

<s:property value="specialString" />
Blake Pettersson