Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

image upload

 
apurv suthar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey frnds....i need help. I wants to make a jsp page that takes image from user and store it into the mysql database and use it on another jsp page.....
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

There are four separate problems here:
1) Send the image from the browser to the server. Use a form like this:
(Replace xxx as required)
This way the file data will be available on the server, as long as you handle it properly.

2) Read the image data on the server. Check out http://www.coderanch.com/how-to/java/FileUpload.

3) Put the image data into the database. Use a PreparedStatement with setBinaryStream.

4) Show the image. You shouldn't do this directly using a JSP; those are not meant for binary data. Instead, use a servlet to display the image. In the JSP you can use a simple <img> tag with the src attribute set to the servlet (possibly with parameters). For example:
getimage is then a URL mapping to the servlet. This servlet takes the id parameter and uses it to retrieve and output the image data.


Oh, and please UseRealWords: "friends", not "frnds".
 
apurv suthar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help....It's quite helpful...and I will take care of following standard of using realword!!!haha
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic