• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

accessing files on the server

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m creating a jsp which calls a bean to search a file on the server.Next the bean returns a Vector of strings as absolute paths to the file on the server.The same path is passed to href tag to give links to the file name in generated html page.But since the path string gives path from the root drive on the server ,Clicking on the link gives an error saying file not found .It is obvious that the absolute path that bean returns is on the server and not on clients machine.
Should i give relative URL wrt the web directory.
Suppose on the server ,The bean returns a path like:
and that my jsp files on jakarta Tomcat server are in "
can i extract the substring as "webapps/prabhat/prabhat.doc" and give the following href tag in the generated Html file.
"<A Href='../webapps/prabhat/prabhat.doc'></a\A>"
Will this tag work.
I want to open MS word files in IE browser by the above method.
If files are not in the Web servers Directory but rather in some other directory on the server say
"d:\temp\prabhat.doc" then how to give the right path in html to open that file.
Please help.
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the file exists under a webapp, you give the url without the directory webapp
/prabhat/prabhat.doc This will allow the request to use the other prabhat webapp to serve the file.
Most servers will not serve up a file that is not under a defined webapp. Thank God! (Or the author of the webserver) This would be a huge hole that would open your server to all kinds of hacking!
If you need to allow access to the file, put it under a webapp.
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic