title: jsp:useBean with Simple Singleton
body: <p>I have a class that I'm trying to retrieve a variable value from on my jsp page but because it's a Singleton, it seems to be having issues.</p>
  
  <p><strong>MyController.java</strong></p>
  
  <pre><code>public class MyController {
  
      private static volatile MyController myController = new MyController();
      private Integer id;
  
      private MyController() {
      }
  
      public static MyController MyController() {
          return myController;
      }
  
      public void display() {
          id = 1;
      }
  
  }
  </code></pre>
  
  <p><strong>test.jsp</strong>:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Test&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;jsp:useBean id="myController" scope="application" class="test.controller.MyController"/&gt;
          &lt;p&gt;
              The ID is: ${myController.id}!
          &lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Error</strong>:</p>
  
  <blockquote>
    <p>org.apache.jasper.JasperException: java.lang.ClassNotFoundException:
    org.apache.jsp.test_jsp</p>
  </blockquote>
  
  <p>Also, I'm not sure how to call the <code>display()</code> method from the jsp page to initialize the <code>id</code> variable?</p>