0
I am trying to implement Httpsession in my code but is giving an error in
request getsession() what it says The method getSession() is Undefined for the type Httprequest
My code
import java.io.IOException;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import DAO.LoginDao;
import Impl.LoginimplDAO;
import classhiber.Utilizador;
@ManagedBean(name = "Login")
@SessionScoped
public class Login {
@Autowired
public String user;
private HttpRequest request;
@Autowired
public String pwd;
@Autowired
private LoginDao log;
public Login()
{
log = new LoginimplDAO();
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public void red () throws IOException
{
FacesContext context = FacesContext.getCurrentInstance();
List<Utilizador> result = log.findlogin(getUser(), getPwd());
if(result.isEmpty())
{
context.addMessage(null, new FacesMessage("Erro", "Falhado") );
}
else
{
//Contar objectos da lista
System.out.println(result.size());
HttpSession sessao = request.getSession();
context.addMessage(null, new FacesMessage("Sucesso", "Login") );
}
// FacesContext.getCurrentInstance().getExternalContext().redirect(
// FacesContext.getCurrentInstance().
// getExternalContext().getRequestContextPath() + "/registar.xhtml");
}
}
Does anyone know what might be causing this mistake ?
Thank you.