• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session atribute handler problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic