0
votes

I wanted to have one jsp page conditionally post to two different Struts actions. So I wrote this:

<logic:notEmpty property="foo"> 
  <html:form action="modifyUser">
</logic:notEmpty>
<logic:empty property="foo"> 
  <html:form action="modifySelf">
</logic:empty>
the body of the page
</html:form>

As a result I got this

Compilation of JSP File '/tiles/user/modify.jsp' failed:

modify.jsp:8:2: No end tag found.
<html:form action="modifyUser">
 ^-------^
modify.jsp:8:2: No end tag found.
<html:form action="modifyUser">
 ^-------^
modify.jsp:11:2: No end tag found.
<html:form action="modifySelf">
 ^-------^
modify.jsp:11:2: No end tag found.
<html:form action="modifySelf">
 ^-------^
modify.jsp:109:3: No start tag found.
</html:form>
  ^-------^
modify.jsp:109:3: No start tag found.
</html:form>
  ^-------^

I am guessing that the parser is looking for forms before logic, or at least matching all the tags.

Any thoughts on how to get the same effect? I am running within tiles also.

1

1 Answers

1
votes

One solution:

 <%String formAction=""; %>

 <logic:notEmpty property="foo"> 
  <% formAction="modifyUser" %>
 </logic:notEmpty>

 <logic:empty property="foo"> 
  <% formAction="modifySelf" %>
 </logic:empty>

 <html:form action="<%=formAction%>