wood burning stoves 2.0*
The moose likes Servlets and the fly likes Storing images in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Storing images in database" Watch "Storing images in database" New topic

Storing images in database

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753

I'm using MySQL as backend,

JSP Code :

Servlet Code :

Servlet Outout in console :

How do i store image in database, I've created one field in table for imahges as follows

Can anybody guide me for the same ???

Jigar Naik

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

are you using a multipart request? If not, or it doesn't ring a bell, then your upload will not work and won't get to the server. You should check our FAQ entry on FileUpload
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
getting folling error :

my jsp code :


Servlet code :

can anybody resolve this error ???

and how this code works ??? i m not saying anything like getParameter("upload"); What if my form is having some other input type=text ???
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream

Learn to read stack traces.

Find the jar containing this file, add it to the container.
Seevai Nalinda

Joined: Apr 12, 2007
Posts: 1
Hi Jigar,

Download the I/O library (commons-io-1.2.jar) from Apache Commons project and stick into the lib directory. That will resolved the NoClassDefFoundError exception.

File upload handles in a different manner. If you want to retrieve the standrd form items such as text fields you have to access them using the isFormField method of FileItem class.

Hope this would help.

subject: Storing images in database
Similar Threads
Getting "not a multipart request" even though the image is being saved.
display multiple images from a mysql table to jsp
servlet or jsp page with prefilled forms
Securing email forms