title: Why am I getting this error using if statement in jsp?
body: <p>Here is my code for the LoginServlet class.</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      String userName = request.getParameter("username");
      String password = request.getParameter("password");
  
      boolean loginFailed;
  
      User user = null;
  
      user = loginService.getUser(userName);
  
      if(user != null &amp;&amp; user.getPassword().equals(password)){
  
          userType = loginService.getUserType(user).getUser_type();
  
          if(userType.equals(USER_TYPE_CUSTOMER)){
              HttpSession session = request.getSession();
              session.setAttribute("username", user.getUsername());
              response.sendRedirect("home_customer.jsp");
          }else{
  
          }
      }else{
          loginFailed = true;
  
          request.setAttribute("username", userName);
          request.setAttribute("loginFailed", loginFailed);
          RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/login.jsp");
          dispatcher.forward(request, response);
      }
  }
  </code></pre>
  
  <p>I have boolean named loginFailed. It will be give a value true when the user does not have an account. I made a code in my jsp page to check this variable. Here is my jsp code.</p>
  
  <pre><code>&lt;body&gt;
  &lt;div class="container container-table" id="login"&gt;
      &lt;div class="row vertical-center-row"&gt;
          &lt;div class="col-md-4 col-md-offset-4"&gt;
              &lt;div style="background-color: #297f56; padding: 15px; border-radius: 5%;"&gt;
                  &lt;h1 style="text-align: center; color: white;"&gt;JJ STORE&lt;/h1&gt;
                  &lt;% Boolean loginFailed = (Boolean) request.getAttribute("loginFailed");
                     if(loginFailed){
                         out.println("&lt;div class='alert alert-warning'&gt;Warning! Dont submit this.&lt;/div&gt;");
                     }%&gt;
                  &lt;form action="processLogin" method="post"&gt;
                  &lt;div class="form-group" &gt;
                      &lt;label for="email" style="color: white;"&gt;Username:&lt;/label&gt;
                      &lt;input type="text" class="form-control" name="username"  value="${username}"&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="pwd" style="color: white;"&gt;Password:&lt;/label&gt;
                      &lt;input type="password" class="form-control" name="password"&gt;
                  &lt;/div&gt;
                  &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>I am not sure what is the problem here. I tried changing the condition in the if block by putting "true" and code went smoothly. However, if I put the boolean I got from the servlet, it gives me this error. </p>
  
  <p><a href="http://i.stack.imgur.com/sS5yl.png" rel="nofollow">enter image description here</a>   </p>
  
  <p>What am I doing wrong?</p>