Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Accessing a web folder in action class

 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David. I got the ServletContext instance from ServletActionContext and it works as I want it to.
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic