• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session atribute handler problem  RSS feed

 
Mat Sergino
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what i'm doing in my application .... in one of my method which is executing during authentication process I set the login attribute by:

public void setSession(){
// Set session Object in Session
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
httpSession.setAttribute("login", this.login);
}


After the authentication process the user can see some links on his page. When the user clicks on one of the links I redirect him the Brit report by url:

http://"+"ip_addr"+":8080/Files/frameset?__report="+report.reportPath


In the report before executing I try to access the attribute I set before by using the code:
var request = reportContext.getHttpServletRequest();
var login = request.getSession().getAttribute("login");


After that I receive null login variable.

I've deployed my application and the runtime Birt engine on Tomcat, and, as I described, I execute Birt reports from my application by url. Is it possible to access the session attribute from another instance of application on tomcat?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are domain and context dependent. Verify if you're really using the same session. You can use HttpSession#getId() for this.

By the way, FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("login", login) does effectively the same. Also, ExternalContext#getSession() returns the HttpSession. Although, a more clean approach is to use just a session scoped bean and set some token (the User property?) in there.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!