I am working on project which needs to display images and text on the browser.I have stored the image in the database in the blob field. I am extracting the blob image from the database and storing it in a byte field. And then using the fileoutputStream to store image in the webcontent folder. To fetch the image i am providing the url of the image to the src tag.
code for DAO class is
while (rs.next())
{
Profile = new UserProfilePojo();
Profile.setImage1(rs.getBlob(14));
list.add(Profile);
}
rs.close();
code written in pojo class is
public byte[] getImage()
{
return barr;
}
public void setImage(Blob image1)
{
try
{
this.barr =image1.getBytes(1,(int)image1.length());
byte[] thumbbarr=resizeImageAsJPG(barr,200);
FileOutputStream fout=new FileOutputStream("E:\\my work\\redirecttest\\WebContent\\"+idm+fname+".jpeg");
fout.write(thumbbarr);
fout.close();
}
catch(NullPointerException | SQLException | IOException n)
{
n.printStackTrace();
}
on the jsp page it is written as
<img src="${Profile[0].id}${Profile[0].fname}imp.jpeg">
Although i am able to fetch the image but i have to refresh the webcontent folder after page load and then refresh the page to display the image.
I just wanted to ask that am i able to run this when the project will be uploaded to the remote server. If so then what should be the location of the fileoutputstream. And if it won't work then please give me some suggestion to display image and data simultaneously on the browser from database.
Thanks