title: Exception while accessing data in JSP file (within scriptlet) forwarded from sevrlet
body: <p>I’m trying to access in a JSP file data send from a Servlet. 
  I’m getting an Exception whenever I run the project.
  I have already tried using<br>
  - <code>&lt;% … %&gt;</code><br>
  - <code>${…}</code><br>
  - <code>&lt;c:out value="${loginFailed}"/&gt;</code></p>
  
  <p>Even when I attempt to use the commenting tag  an Exception will arise.</p>
  
  <p>I’m clueless, any help will be welcome.    </p>
  
  <p><strong>Some of my reading/research</strong>    </p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/tags/el/info">https://stackoverflow.com/tags/el/info</a><br>
    <a href="https://www.tutorialspoint.com/jsp/jsp_actions.htm" rel="nofollow noreferrer">https://www.tutorialspoint.com/jsp/jsp_actions.htm</a><br>
    <a href="https://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files/3180202#3180202">How to avoid Java code in JSP files?</a><br>
    ...</p>
  </blockquote>
  
  <p><strong>login.jsp</strong>    </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"&gt;
      &lt;jsp:directive.page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" /&gt;
      &lt;jsp:text&gt; &lt;![CDATA[ &lt;?xml version="1.0" encoding="UTF-8" ?&gt; ]]&gt; &lt;/jsp:text&gt;
      &lt;jsp:text&gt; &lt;![CDATA[ &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; ]]&gt; &lt;/jsp:text&gt;
  
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
          &lt;head&gt;
              &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
              &lt;link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/styles/login/css/style.css" /&gt;
              &lt;title&gt;Connexion&lt;/title&gt;
          &lt;/head&gt;
  
          &lt;body&gt;
              &lt;form class="sign-up" method="Post" action="/TP1MiniProjetBanque/home"&gt;
                  &lt;h1 class="sign-up-title"&gt;Connexion&lt;/h1&gt;
                  &lt;input type="text" name="mail" class="sign-up-input" placeholder="Mail"/&gt;
                  &lt;input type="password" name="mdp" class="sign-up-input" placeholder="Mot de passe"/&gt;
  
                  &lt;input type="submit" value="Entrer" class="sign-up-button"/&gt;
              &lt;/form&gt;
  
              &lt;% out.println((String)request.getAttribute("loginFailed")); %&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p><strong>JRServlet.java</strong>    </p>
  
  <pre><code>protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.getWriter().append("Served at :").append(request.getContextPath());
      request.getRequestDispatcher("/login.jsp").forward(request, response);
  }
  
  
  protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      String mail = request.getParameter("mail");
      String mdp  = request.getParameter("mdp");
  
      if (mail.isEmpty() || mdp.isEmpty() || /**/) {
          request.setAttribute("loginFailed", true);
          request.getRequestDispatcher("/login.jsp").forward(request, response);
          return;
      } else {
          Client  user = new Client(mail, mdp);
  
          request.getRequestDispatcher("/home.jsp").forward(request, response);
          return;
      }
  
      //doGet(request, response);
  }    
  </code></pre>
  
  <p><strong>web.xml</strong>    </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://java.sun.com/xml/ns/javaee"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
  
    &lt;display-name&gt;TP1MiniProjetBanque&lt;/display-name&gt;
  
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;home&lt;/servlet-name&gt;
      &lt;servlet-class&gt;jrservlet.JRServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;home&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/home&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;    
  </code></pre>
  
  <p><strong>The hierarchy</strong>    </p>
  
  <pre><code>workspace/TP1MiniProjetBanque/    
  ├── build    
  │   └── classes    
  │       └── jrservlet    
  │           ├── Client.class    
  │           ├── Compte.class    
  │           ├── DB.class    
  │           ├── JRServlet.class    
  │           └── testing.class    
  ├── src    
  │   └── jrservlet    
  │       ├── Client.java    
  │       ├── Compte.java    
  │       ├── DB.java    
  │       ├── JRServlet.java    
  │       └── testing.java    
  └── WebContent    
      ├── home.jsp    
      ├── login.jsp    
      ├── META-INF    
      │   └── MANIFEST.MF    
      ├── styles    
      │   ├── home    
      │   └── login    
      └── WEB-INF    
          ├── lib    
          │   └── mysql-connector-java-5.1.39-bin.jar    
          └── web.xml    
  </code></pre>
  
  <p><strong>The error I get when launching the Servlet</strong>    </p>
  
  <p><em>HTTP Status 500 - /login.jsp (line: 23, column: 11) The content of elements must consist of well-formed character data or markup.</em></p>
  
  <p>type Exception report</p>
  
  <p>message /login.jsp (line: 23, column: 11) The content of elements must consist of well-formed character data or markup.</p>
  
  <p>description The server encountered an internal error that prevented it from fulfilling this request.</p>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>org.apache.jasper.JasperException: /login.jsp (line: 23, column: 11) The content of elements must consist of well-formed character data or markup.
      org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
      org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
      org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:308)
      org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:228)
      org.apache.jasper.compiler.ParserController.doParse(ParserController.java:226)
      org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      jrservlet.JRServlet.doGet(JRServlet.java:41)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  root cause
  
  org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 11; The content of elements must consist of well-formed character data or markup.
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
      com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1437)
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(XMLDocumentFragmentScannerImpl.java:2637)
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2735)
      com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
      com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
      com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
      com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
      com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
      com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
      org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:195)
      org.apache.jasper.compiler.ParserController.doParse(ParserController.java:226)
      org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      jrservlet.JRServlet.doGet(JRServlet.java:41)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs.
  </code></pre>
  
  <p>Apache Tomcat/7.0.70</p>