i tried to insert the image into mysql and retrive it into the borwser in javaservlet using resin web server. i can successfully insert the image into the datbase. but i faced some difficulties when i tried to retrive the image from mysql database to the browser. i used the blob datatype for storing images. i can able to retrieve the binary value of the image. my difficuties:------------- 1. how can we convert the binary value of one image into string value and store it into database? 2. i have two fields in my database 1. text 2. image if give the text as an input thru browser, it should be comapred with the text which is already stored in the database. if the comparision is succeed then it refer the binary value of the corespondent image to the input text. and store this in mirror table and once again compare with the image from the orginal datbase. if they matched then retrive the coresspondent text to foreground.
pls help me.
posted 13 years ago
if you want to convert the binary value of image/any binary file then you can use Base64 encoding to convert to ASCII string and when required you can decode it and write directly to servlet stream. Base64 encoder and decoder can be found in sun.misc.util package if i remember correctly.