*
The moose likes Servlets and the fly likes how to include jpg file on server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to include jpg file on server" Watch "how to include jpg file on server" New topic
Author

how to include jpg file on server

Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
Hello
I am doing project of shopping cart.. in which admin can log in and add the product to his site.. so how to add jpg file of the product on the server.. for copying image I am using FileInputStream and FileOutputStream. but what path should I give to upload file on the server .. suppose I stored images on web-apps\ShoppingCart(projectName)\Images(folderName).

I am using apache web server..

suppose there is file named Laptop.jpg on my desktop.. and I logged in as an admin. so I am giving path to upload file Images/Laptop.jpg... but its giving me an error


SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Make use of ServletContext#getRealPath() to convert a relative web path to an absolute file system path which you on its turn can use in File/FileInputStream.
Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
Thank you... itzz working
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to include jpg file on server