This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

image upload

 
apurv suthar
Ranch Hand
Posts: 35
  • 0
  • 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: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • 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: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic