wood burning stoves 2.0
The moose likes JSP and the fly likes Path to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Path to a file" Watch "Path to a file" New topic

Path to a file

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
Hi all,
I have a site for uploading photos. Each upload is put into a photoAlbum( a file- sub directory)
I have a JSP page that goes through all of these files and selects the first photo whose path is stored in a String array and then they are all displayed as the home page.
The problem I am having is that the only way I can get it too work is by hard coding the path to the file where that contains my pages for the whole site, "C:\Apache\webapps\PhotoAlbums"
I am concerned that this does not make it very portable. What I am after is somehow having a File pointer to "\webapps\PhotoAlbums" this what I can simply move the PhotoALbums directory without changing the code.
Any ideas?
Trish Wu
Ranch Hand

Joined: Oct 09, 2002
Posts: 34
application.getResourcePaths(java.lang.String path)
application.getRealPath(java.lang.String path)
application is an implicit variable of javax.servlet.ServletContext
Put the hard coded path in the web.xml as an init-param
david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
thanks for that. That is what I am after.
I agree. Here's the link: http://aspose.com/file-tools
subject: Path to a file
It's not a secret anymore!