Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes Uploading a Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading a Image" Watch "Uploading a Image" New topic
Author

Uploading a Image

Anchal Bhargava
Greenhorn

Joined: Jul 22, 2012
Posts: 6
How Can I upload a Image From a jsp page and Store it into Database
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32501
    
214

Welcome to CodeRanch!

There are three parts to your question:
1) How to upload an image - look at the apache commons file upload library
2) Do you want to store the file in the database or on the file system with the database pointing to it.
3) How to store the file/reference in the database - read about JDBC and BLOBs

Note that most of this is done in a servlet or helper class rather than a JSP. JSPs are just for presentation.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63224
    
  69

Please read the JspFaq prior to posting.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anchal Bhargava
Greenhorn

Joined: Jul 22, 2012
Posts: 6
Thanks for your reply, I know that jsp is for presentation I mean that I have created a form in jsp and want to upload a image not reference, the actual image in Database
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19728
    
  10

It still isn't clear to me what you are asking. Let me post this answer and see if it belongs to your question:

The form in the HTML which your JSP generates should have enctype="multipart/form-data" and method="post". In addition it should contain an <input> element with type="file".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63224
    
  69

Did you read the JspFaq?
 
Have you checked out Aspose?
 
subject: Uploading a Image
 
It's not a secret anymore!