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 How to get ServletConfig and ServletContexts in Action class of struts 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 "How to get ServletConfig and ServletContexts in Action class of struts" Watch "How to get ServletConfig and ServletContexts in Action class of struts" New topic
Author

How to get ServletConfig and ServletContexts in Action class of struts

sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
HI,

How to get ServletConfig and ServletContext in Action class of struts.

so that i can use context object to store user sessions..

Help me out..

Thank You
J Sreenivas
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The class org.apache.struts.action.Action that your action class extends has a getServlet() method that returns the instance of ActionServlet that called your action. Once you have the servlet, you can get the servlet context. Example:


Merrill
Consultant, Sima Solutions
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Thanks merrill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get ServletConfig and ServletContexts in Action class of struts