This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes [UserDispatchAction] retrieve attribute from servlet context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "[UserDispatchAction] retrieve attribute from servlet context" Watch "[UserDispatchAction] retrieve attribute from servlet context" New topic
Author

[UserDispatchAction] retrieve attribute from servlet context

Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
Hi there,
on a plugIn class I store a properties object in the servlet context, like this:
ServletContext context = servlet.getServletContext();
context.setAttribute(Constants.ROLES, roles);

the question is, why if I try to retrieve that object in this way from a DispatchAction, I get a null object
private Properties props = (Properties)servlet.getServletContext().getAttribute(Constants.ROLES);

while inside the method, like this, it works fine?
Properties roles = (Properties)request.getSession(false).
getServletContext().getAttribute(Constants.ROLES);

Can you tell me if this way will strongly affect the performance?

Thanks in advance


trying to decode a woman mind....
 
 
subject: [UserDispatchAction] retrieve attribute from servlet context