This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am developing a book store web application where admin uploads the books and those books are displayed on the JSP Page. Admin inserts name, author and physical path of book image. All are stored in db and image is also saved on the location given in physical path. Image is uploaded using Apache commons library.
Problem occurs when records are displayed but image does not although image is physical present in the location. I have used several ways to display the image but none has worked. Although hard coded path displays the image. Following are few ways i have used in JSP file:
You will never, ever be able to access an image that is stored in a server using a path like c:\\..., you must understand that c:\\ is a local path related to your server and you are trying to access the image from a client that is not in the same machine. Let alone the security problems that has the fact that someone would be able just to access files directly in the server using a simple path...
You have to deploy the images in your server, just like your JSPs an access them the same way. For example if you have them under WebappRoot/web/images, then you can access them just as if they were a js file, a css or whatever.
If you have them in your server maybe you are just forgetting the context path. Other thing, that you have them in your workspace does not automatically mean that they are deployed in your server.