title: How to call a variable with JSP?
body: <p>In JSP I have created a simple variable like this:</p>
  
  <pre><code>&lt;%
      if (request.getSession().getAttribute("user") != null) {
          String status = "online";
      }
      else {
          String status = "offline";
      }
  %&gt;
  </code></pre>
  
  <p>In HTML I call the variable like this: <code>${status}</code></p>
  
  <p>So the string "offline" or "online" would just be a CSS class, as you see in the code below:</p>
  
  <pre><code>&lt;img class="profile-pic" src="../assets/img/reza.png" alt="Chin"&gt; &lt;i class="status ${status}"&gt;&lt;/i&gt;Reza
  </code></pre>
  
  <p>So the whole code looks like this:</p>
  
  <pre><code>&lt;%
      if (request.getSession().getAttribute("user") != null) {
          String status = "online";
      }
      else {
          String status = "offline";
      }
  %&gt;
      &lt;div class="user-section"&gt;
          &lt;img class="profile-pic" src="../assets/img/reza.png" alt="Chin"&gt; &lt;i class="status ${status}"&gt;&lt;/i&gt;Reza
      &lt;/div&gt;
  </code></pre>
  
  <p>but from Intellij I get the warning:</p>
  
  <blockquote>
    <p>Cannot resolve variable 'status'</p>
  </blockquote>
  
  <p>How can I fix this?</p>