title: Whitespace before XML declaration from JSP
body: <p>I'm trying to achieve full XHTML transitional validation of my JSP output but I've hit a snag. The top of the header looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  </code></pre>
  
  <p>It is included with a statement that looks like this:</p>
  
  <pre><code>&lt;jsp:include&gt;
    &lt;jsp:attribute name="page"&gt;&lt;owportal:page name="/style/portal/header.jsp" /&gt;&lt;/jsp:attribute&gt;
  &lt;/jsp:include&gt;
  </code></pre>
  
  <p>The &lt;owportal:page&gt; tag checks a few different paths so that we can override it with a project-specific header if need be. The problem with this is the owportal taglib needs to be declared before it can be used, inserting a blank line before the XML declaration and causing a validation warning.</p>
  
  <p>I have tried using jsp:output to <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajq.html#bnajz" rel="nofollow noreferrer">generate an XML declaration</a> without much luck. Can anyone let me know if I'm on the right track here?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Currently I'm trying something like this</p>
  
  <pre><code>&lt;%@ taglib uri="/WEB-INF/yadda/yadda" prefix="yadda" %&gt;
  
  &lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.0"&gt;
    &lt;jsp:output omit-xml-declaration="false" doctype-root-element="html"
                doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
                doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/&gt;
  &lt;/jsp:root&gt;
  
  &lt;html&gt;...
  </code></pre>
  
  <p>And I am getting an error "Invalid standard action" at the &lt;jsp:root&gt; line. Not the most helpful error message. Sounds like I'm using the tag wrong somehow perhaps. I'm running Tomcat 6 so it shouldn't be a problem with the JSP version. Can anyone see what I'm doing wrong? Is &lt;jsp:root&gt; meant to wrap around &lt;html&gt;?</p>