aspose file tools*
The moose likes Struts and the fly likes Struts2 Accessing a web folder in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
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://aspose.com/file-tools
 
subject: Struts2 Accessing a web folder in action class