This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Accessing a web folder in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Struts2 Accessing a web folder in action class" Watch "Struts2 Accessing a web folder in action class" New topic
Author

Struts2 Accessing a web folder in action class

Harsha Pherwani
Greenhorn

Joined: Jul 11, 2005
Posts: 27
Hi all,

In the action class, I would like to access the images folder located in the application alongside WEB-INF.
The directory structure looks like this -

Tomcat -> webapps -> app
-> images
-> jsp
-> WEB-INF

Is there a struts api that gives me the absolute path till the application?

Thanks!
Harsha


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

There's no Struts 2 API for that; you'd just use the regular ServletContext.getRealPath().

You can either implement ServletContextAware or use the ServletActionContext utility class.
Harsha Pherwani
Greenhorn

Joined: Jul 11, 2005
Posts: 27
Thanks David. I got the ServletContext instance from ServletActionContext and it works as I want it to.
Thanks!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Struts2 Accessing a web folder in action class
 
Similar Threads
web app structure
fragment was not found error
Getting out of WEB-INF
what is document root?
invalid console appender .....