I put the object into the session:
session.setAttribute("userDTO", currentUser);
And I'm trying to display it using EL. I succeeded with scriplets (proving that the object is set perfectly in the session).
Code in JSP:
<body>
<% UserDTO userdto=(UserDTO)session.getAttribute("userDTO"); %>
<%=userdto.getUsername() %>
Username from session:<c:out value="${sessionScope.userDTO.username }"/>
</body>
The scripts display the username, but after "Username from the session" nothing is displayed. Why?
UserDTO Class:
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;
}
}
source
share