Passing data from Action to JSP

Print

 

Usual way of passing data from the action, or a Servlet, to a jsp page is placing them as a request/session attribute. Then the only way to use them is getting the Object back with a known attribute name and casting it to the correct type. This can lead to perform many cast operations.

Javajax offers an easier and safer way: since the called Action is passed to the jsp, result data can be placed in the action as a class attribute with public getter, and use the accessor in the jsp page to retrieve your data. 

The "action" jsp tag can be used to retrieve a specific action:

<javajax:action type="actions.Myaction" id="myAction"/> 



Now you can get your data back:

<%
MyBean data = myAction.getMyData();
%>