title: JSTL throws Exception when running JSP
body: <p>I'm currently starting to test out JSTL as a replacement for scriptlets, and from a (german) sample page I've copied the following code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0" xmlns:a4j="http://richfaces.org/a4j"&gt;
      &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  
      &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"&gt;
          &lt;head&gt;
            &lt;title&gt;JSTL 1.1&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;h1&gt;Iteration&lt;/h1&gt;
  
              &lt;ul&gt;
                &lt;c:forEach var="num" begin="1" end="10"&gt;
                  &lt;li&gt;Nummer &lt;c:out value="${num}"/&gt;&lt;/li&gt;
                &lt;/c:forEach&gt;
              &lt;/ul&gt;
  
              &lt;h1&gt;Formatierung&lt;/h1&gt;
  
              &lt;p&gt;
                Währung: &lt;fmt:formatNumber value="10000" type="currency" currencyCode="EUR" /&gt;
              &lt;/p&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>My application container is Tomcat 7.0, the JSTL library is linked to the project (there's a different error message when it's not). Calling the listed JSP from the browser on my local installation throws this error message:</p>
  
  <pre><code>Jul 03, 2013 2:56:58 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [jsp] in context with path [/webapp01] threw exception [org.apache.jasper.JasperException: /test.jsp (line: 3, column: 3) Der Content von Elementen muss aus ordnungsgemäß formatierten Zeichendaten oder Markups bestehen.] with root cause
  org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 3; Der Content von Elementen muss aus ordnungsgemäß formatierten Zeichendaten oder Markups bestehen.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(XMLDocumentFragmentScannerImpl.java:2567)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2665)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
    at org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:172)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:226)
    at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:193)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>It definitely seems to complain about the <code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;</code>, however, I will need to actually load the namespace definitions for JSTL 2.0, don't I?</p>
  
  <p>Edit 1: Removing the manual (and wrongly formatted) import of the taglib results in an error message that I was trying to fix with the manual import:</p>
  
  <pre><code>This page contains the following errors:
  
  error on line 1 at column 110: Namespace prefix c on forEach is not defined
  error on line 2 at column 56: Namespace prefix fmt on formatNumber is not defined
  </code></pre>
  
  <p>I found somewhere that this was because the JSTL could not be found. However, I've added the <code>jstl-1.2.jar</code> to the project. Also, I read that this problem could be caused by not having the right Tomcat version. However, I'm pretty sure I'm running Tomcat 7.</p>