Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Struts
How to Access SevletContext Object in Action Class
Sarath Mohan
Ranch Hand
Posts: 213
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How to Access ServletContext Object in Action Class?
If you have code please put it also
Thanks
Sarath Mohan
Franck Tranchant
Ranch Hand
Posts: 75
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
First, get the Session then you can access the associated ServletContext.
import javax.servlet.ServletContext import javax.servlet.http.HttpSession import javax.servlet.http.HttpServletRequest <...> public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws SessionException { <...> HttpSession session = getSession(request); ServletContext context = session.getServletContext(); <...> }
Franck<p>--------------------
Sarath Mohan
Ranch Hand
Posts: 213
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot Frank.
I declared a datasource in the struts-config file.
Now I need to get the datasource object in the action class.
So by using ServletContext Object I can access the same.
Is there any other way to access?
Regards
Sarath Mohan
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
About the request processor
DWR questions
Accessing the ActionForm inside a Servlet Filter
Access session object in struts1 action or formbean
How to access the request object in struts2 action
More...