-1

Working on NetBeans 6.8 ... Java web application
Assume the current location/directory is (default) web folder and the file executed is index.jsp which is in the web folder.

I have created a folder named 'a1' inside the web folder and folder 'a2' inside the 'a1' folder.

web --> a1 --> a2
Each folder contains Image.png

<a href="Image.png">Image</a> // works when clicked on the link
<a href="/a1/Image.png">Image</a> // works when clicked on the link
<a href="/a1/a2/Image.png">Image</a> // does not work !!!!!!!

Any file which is more than 1 folder deep generates the error 'resource not found'
Why is this happening?

user646093
  • 1,495
  • 3
  • 15
  • 20
  • I just tried. It works on my machine. What server are you using(tomcat,glassfish)? Does your server have reading rights on the a2 directory? – Voooza Apr 16 '11 at 15:02
  • i am using glassfish server...I dont know how i can configure the glassfish server for reading rights... The error occurs for any folder which is two or more levels deep...I tried using different files (different extensions)...different folders...using href="a1/a2/Image.png" (instead of /a1)...but none of them worked – user646093 Apr 16 '11 at 15:25
  • After 3 hours i found where the problem was... Folders which are created after the build and run process (in Netbeans) are not recognized by the glassfish v3 server !!!!!!!!!!!!! Folders are created dynamically in my project hence the problem... These folders are created when users upload files... And download links are provided to the users respectively... Now I have to find a way to provide the files for download to the users in some other way!! – user646093 Apr 16 '11 at 16:02

1 Answers1

0

Looks like you have some sort of resolution but it doesn't seem to be the optimal approach. Instead of saving image files on the disk, how about streaming it off of the server by storing them in databases. Upon Upload, store the images in database as Blob and serve the images later using a servlet. Please take a look at Apache File Upload

Piyush Mattoo
  • 15,454
  • 6
  • 47
  • 56
  • Assume i storing the uploaded file in C:\temp folder... and my Netbeans project path is C:\NetBeans\WebApplication3...Is there any way i can stream or make the files in **C:\temp folder** available for download..... I do not want to insert binary data in database...Please read the comments in [retrieving-binary-data-varbinarymax-from-sql-server-2008-using-jsp] (http://stackoverflow.com/questions/5606161/retrieving-binary-data-varbinarymax-from-sql-server-2008-using-jsp) .....Thanks for helping !!!! – user646093 Apr 17 '11 at 10:25
  • What makes you assume that it is not a good idea to store images in database in your case? Please look into this post http://stackoverflow.com/questions/1010652/store-imagesjpg-gif-png-in-filesystem-or-db to come to the right conclusion. – Piyush Mattoo Apr 18 '11 at 05:26