Search code examples
javajspstruts

Parsing Struts tag using s:property


In one of our challenging application, I am generating few struts tag dynamically in Action class Once I generated the struts tag, I want it to get it parsed through s:property

in my JSP:

<s:property value='generateElement("ABC")' escape='false' />

in my Java Action

public String generateElement(String element){
     return "<s:select id='aaaa' list=\"{'1':'1','2':'2'}\" >";
}

in the end I want to generate Selection box.

How do I achieve this.


Solution

  • You can't execute JSP code after the JSP has been compiled. So there's no use in returning a JSP tag in your method. Instead, generateElement should return the objects that you need in your select, and then reference that property in a <s:select> tag that is already in your JSP.