• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get servlet context or similar object in Struts

 
Dhiren Joshi
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need handle to ServletContext becuase I need the access to this method .
getRealPath() in servlet context. Can any one tell me how I could get this using Struts in my Action classes.

Thanks
Dhiren
 
Samuel Cox
Ranch Hand
Posts: 96
Scala Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For struts 1.1 (not sure on latest):


[ June 17, 2005: Message edited by: Samuel Cox ]
 
Dhiren Joshi
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can make this call even in Struts action classes ?

this.getServlet().getServletContext().getRealPath("blah");

Thanks
Dhiren
 
Samuel Cox
Ranch Hand
Posts: 96
Scala Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I have never used the getRealPath(String) method, but I have used other methods of ServletContext from our Action classes (execute method) using that construct.

Remember, that was for struts 1.1. You'll need to make sure you can do this for whatever version you are using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic