I'd like to know if it's possible to check with the <s:if> tag of Struts 2 if the user is in session.
If the user is in session, I need it to be shown Logout otherwise Login.
I use the interface SessionAware for login action and this class User.
package it.pwm.wynd.pojo.user;
public class User implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer idUser;
private String name;
private String username;
private String password;
private String email;
public User() {
}
public User(String name, String username, String password, String email) {
this.name = name;
this.username = username;
this.password = password;
this.email = email;
}
public Integer getIdUser() {
return this.idUser;
}
public void setIdUser(Integer idUser) {
this.idUser = idUser;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
}
Struts2 tags cannot work without associated filer. If you use Struts tags in JSP make sure you read first about tags.
The session map can be injected into the action if it is
SessionAware.In the JSP you could check the
userin session with the<s:if>tag using a#sessioncontext variable.