java - get the struts.xml action name in jsp -


this question has answer here:

i have struts.xml like

<action name="actionname" class=myclass" method="mymethod">              <result name="success" >/web-inf/jsp/fold/myjsp.jsp</result>                 <result name="failure" >/web-inf/jsp/fold/myresult.jsp</result>         </action>  

based on success or failure corresponding pages displayed. want action name in jsp in case of failure.

is possible ?

if want name of action thats being executed inside action, in action execute method try like:

 string actionname = actioncontext.getcontext().getname(); 

next, create member variable store action name in action class (ex: actionname)

private actionname; //set , method 

last, use property tag display action name in failure page called myresult.jsp.


Comments