Thanks for responding to my question. However, JBoss server does not explode
the war deployed to it. Unlike tomcat, it does explode the war file, and this
is why it is easy to access files within a war file.
Here's is my code
private HttpServletRequest servletRequest;
@Override
public void setServletRequest(HttpServletRequest httpServletRequest) {
// TODO Auto-generated method stub
this.servletRequest = httpServletRequest;
}
String filePath =
servletRequest.getSession().getServletContext().getRealPath("/MyApp/web/jasper/jasperReport.jasper");
However, I am getting the following path when debugging the above code:
C:\jboss-6.0.0.Final\server\default\tmp\vfs\automounta5bfada4df82fa0e\MyApp.war-ec6d753dd0506906\web\jasper\jasperReport.jasper.
The JasperReport.jar is located at the MyApp/web/jasper/ folder.
Thanks,
Omar N.
________________________________
From: Maurizio Cucchiara <[email protected]>
To: Struts Users Mailing List <[email protected]>; Omar Ngarigari
<[email protected]>
Sent: Tuesday, July 2, 2013 12:20 PM
Subject: Re: accessing an external file in the struts.xml
Much of the answer depends on what your application server is.
In any case, I don't think this is a good practice. IMO you should include the
file with your webapp and find a way to access to it.
Twitter :http://www.twitter.com/m_cucchiara
G+ :https://plus.google.com/107903711540963855921
Linkedin :http://www.linkedin.com/in/mauriziocucchiara
VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara
Maurizio Cucchiara
On 2 July 2013 18:05, Omar Ngarigari <[email protected]> wrote:
Hello,
>
>Is it possible to access a file that is located in the local drive or server
>side folder from struts.xml? as follow:
>
><result name="success" type="jasper">
><param name="location">C:/Folder/jasperReport.jasper</param>
>or
><param name="location>%{filename}</param> where the filename is avariable in
>the action class with the file location is hardcoded as String filename =
>"C:/Folder/jasperReport.jasper";
>
>
>
>My struts2 application is deployed on JBoss as 6, it seems ServletRequestAware
>is unable to access the folder within war file while working with JBoss. It is
>working fine with tomcat. I am thinking about accessing files in the server
>size instead.
>
>Thanks,
>