• Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing files on the server  RSS feed

 
prabhat gupta
Greenhorn
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:
"c:\jakarta\webapps\prabhat\prabhat.doc"
and that my jsp files on jakarta Tomcat server are in "
"c:\jakarta\jsp\"
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.
 
Carl Trusiak
Sheriff
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!