You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Omar Ngarigari <ng...@yahoo.com> on 2013/07/02 18:05:52 UTC
accessing an external file in the struts.xml
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,
Re: accessing an external file in the struts.xml
Posted by Omar Ngarigari <ng...@yahoo.com>.
I moved the file placed under /WEB-INF directory, but the action class still cannot located the path to the file. Please help...
________________________________
From: Dave Newton <da...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Tuesday, July 2, 2013 1:26 PM
Subject: Re: accessing an external file in the struts.xml
You have at least one extra layer in your file path, normally you'd keep
files like this under WEB-INF, and start the file path from there.
Dave
On Jul 2, 2013 1:14 PM, "Omar Ngarigari" <ng...@yahoo.com> wrote:
> 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 <mc...@apache.org>
> To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <
> ngarigarius@yahoo.com>
> 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 <ng...@yahoo.com> 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,
> >
Re: accessing an external file in the struts.xml
Posted by Dave Newton <da...@gmail.com>.
You have at least one extra layer in your file path, normally you'd keep
files like this under WEB-INF, and start the file path from there.
Dave
On Jul 2, 2013 1:14 PM, "Omar Ngarigari" <ng...@yahoo.com> wrote:
> 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 <mc...@apache.org>
> To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <
> ngarigarius@yahoo.com>
> 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 <ng...@yahoo.com> 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,
> >
Re: accessing an external file in the struts.xml
Posted by Omar Ngarigari <ng...@yahoo.com>.
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 <mc...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <ng...@yahoo.com>
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 <ng...@yahoo.com> 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,
>
Re: accessing an external file in the struts.xml
Posted by Maurizio Cucchiara <mc...@apache.org>.
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 <ng...@yahoo.com> 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,
>