-
1. Re: How do I access a generated file?
lvdberg Nov 1, 2009 11:56 AM (in response to mstang)Hi,
I ususally save them in the always-present root-directory of the server. In my case I use the
JBOSS_HOME
variable which gives me the absolute path to the server dir on disk and work my way up. It's is not easy to use a sub-dir of your own application if you want to preserve the files, because Jboss creates a temporary dir where the deployed dir resides. If you don't care , get the absolute path from the servlet context. With Seam you just inject the FacesContext and you can get the absolute dir from there.
Leo
-
2. Re: How do I access a generated file?
cash1981 Nov 1, 2009 2:47 PM (in response to mstang)You can also take a look here which might be helpful. Personally I always put my files in the database. That way it is much easier to get hold of them.
-
3. Re: How do I access a generated file?
mstang Nov 2, 2009 6:47 PM (in response to mstang)I am able to get access to the root of webapp:
- {request.contextPath
I can create files here, but seam/jboss is blocking my access. I get the error:
The url requested does not exist. Please update your saved bookmarks, or check that requested url is not mistyped.
Why can't I access generated files in the webapp directory???
-
4. Re: How do I access a generated file?
lvdberg Nov 3, 2009 9:13 AM (in response to mstang)To get a specific resource:
@In FacesContext facesContext; ... ServletContext ctx = (ServletContext) facesContext.getExternalContext().getContext(); URL url = ctx.getResource("/subDir/subDir/YourFile");
So if you place your file in the indicated YourFile starting from the root-directory of your application, it should work. However, if you use a WAR-file those files are created in a temporary deploy directory. When the server re-starts after a deploy you won't see the same directory. You can solve that by deploying as an WAR.DIR under your deploy directory. Your application will always atart in the same directory and your files are
persisted
.Leo