• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading a Image

 
Anchal Bhargava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How Can I upload a Image From a jsp page and Store it into Database
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read the JspFaq prior to posting.
 
Anchal Bhargava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20998
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the JspFaq?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic