title: JSTL get object from session
body: <p>I have put an object in the session:</p>
  
  <pre><code>session.setAttribute("userDTO", currentUser);
  </code></pre>
  
  <p>And I am trying to display it using EL. I have succeeded with scriplets (proving that the object is set in the session fine).</p>
  
  <p>Code in JSP:</p>
  
  <pre><code>&lt;body&gt;
      &lt;% UserDTO userdto=(UserDTO)session.getAttribute("userDTO"); %&gt;
      &lt;%=userdto.getUsername() %&gt;
      Username from session:&lt;c:out value="${sessionScope.userDTO.username }"/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>The scriplets display the username but nothing is displayed after "Username from session:". Why?</p>
  
  <p><strong>UserDTO class:</strong></p>
  
  <pre><code>public class UserDTO {
      private int ID;
      private String email;
      private boolean emailConfirmed;
      private String username;
      private String role;
      public int getID() {
          return ID;
      }
      public void setID(int iD) {
          ID = iD;
      }
      public boolean isEmailConfirmed() {
          return emailConfirmed;
      }
      public void setEmailConfirmed(boolean emailConfirmed) {
          this.emailConfirmed = emailConfirmed;
      }
      public String getEmail() {
          return email;
      }
      public void setEmail(String email) {
          this.email = email;
      }
      public String getRole() {
          return role;
      }
      public void setRole(String role) {
          this.role = role;
      }
      public String getUsername() {
          return username;
      }
      public void setUsername(String username) {
          this.username = username;
      }
  }
  </code></pre>