aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Path to a file" Watch "Path to a file" New topic
Author

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?
Thanks
David
Trish Wu
Ranch Hand

Joined: Oct 09, 2002
Posts: 34
Programmatically,
application.getResourcePaths(java.lang.String path)
or
application.getRealPath(java.lang.String path)
application is an implicit variable of javax.servlet.ServletContext
Declarativly,
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.
David
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Path to a file
 
Similar Threads
is there any method for finding
topcat and adding new directory in webapps
Using java-beans in your jsp
Directory structure issue
Redirect a URL