• 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

How to get servlet context or similar object in Struts

 
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 96
Scala VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic