title: Conditionally set an attribute on an element with JSP Documents (JSPX)
body: <p>In HTML forms, buttons can be disabled by defining the "disabled" attribute on them, with any value:</p>
  
  <pre><code>&lt;button name="btn1" disabled="disabled"&gt;Hello&lt;/button&gt;
  </code></pre>
  
  <p>If a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attribute can be set to that would leave the button enabled.</p>
  
  <p>This is causing me problems when I want to enable / disable buttons when using JSP Documents (jspx). As JSP documents have to be well-formed XML documents, I can't see any way of conditionally including this attribute, as something like the following isn't legal:</p>
  
  <pre><code>&lt;button name="btn1" &lt;%= (isDisabled) ? "disabled" : "" %/&gt; &gt;Hello&lt;/button&gt;
  </code></pre>
  
  <p>While I could replicate the tag twice using a JSTL if tag to get the desired effect, in my specific case I have over 15 attributes declared on the button (lots of javascript event handler attributes for AJAX) so duplicating the tag is going to make the JSP very messy.</p>
  
  <p>How can I solve this problem, without sacrificing the readability of the JSP? Are there any custom tags that can add attributes to the parent by manipulating the output DOM?</p>