• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path to a file

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for that. That is what I am after.
David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic