• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving images in database from servlet

 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am developing a shopping cart webapp , i want to know that ,

how to add image in database using servlet as i want to insert images for various products ..

Thanks

Nikesh Shah
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So which part are you having an issue with? The servelt part or the JDBC part? If it's the latter, then I'll move this to the JDBC forum. Let us know.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Actually i have issue with both the parts servlets and jdbc....

would it require any file uploading code or just JDBC insert statement ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can't guess what it is you need to you. Please be detailed in your posts.

Where is the image file coming from?
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would it require any file uploading code or just JDBC insert statement ?


It seems you are not clear about the technology. Since you are a gujarati would like to give some details.

File uploading is different then JDBC insert statement.
File upload gives you data in binary stream.
For storing image in database your database should support blob type.
Moreover it is not advisable to store many images in database, best solution is to store it in a file system(ie. on your machine) and store the path detail in DB.

For file uploading and storing in the database you can use struts framework instead of writing everything by using servlet.

Hope this helps.
 
Sunil Kumar Jakkaraju
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jignesh pointed out, it is not advisable to store image files in database, especially if you are using those images to be rendered on your web applications.

It is better to use a file system and refer to it. It will also be easier to modify the images. It will be more manegable if you want different images to be displayed for specific locales / user groups.

However, if you are allowing the user to upload files to your webapp, then you might need some secure file system to store it. Your webapp may either create a sub directory under that file system for each user or store all the files in the same location.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for the above responses...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic