struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: accessing an external file in the struts.xml
Date Tue, 02 Jul 2013 17:26:54 GMT
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" <ngarigarius@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 <mcucchiara@apache.org>
> To: Struts Users Mailing List <user@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 <ngarigarius@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,
> >

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message