Hi ,
I need help to sort out my problem.I am uploading images into file system
and storing the location in to database.Then i want to display the uploaded
images as view in the jsp page using struts2.
Help me ..
Printable View
Hi ,
I need help to sort out my problem.I am uploading images into file system
and storing the location in to database.Then i want to display the uploaded
images as view in the jsp page using struts2.
Help me ..
Hi,
please follow the below code snippet,
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
getImageFile {
BufferedImage bufferedImage = getImageStream(systemFilePath)
if (bufferedImage) {
try {
response.reset()
OutputStream out = response.getOutputStream()
ImageIO.write(bufferedImage, 'JPG', out)
out.flush();
out.close();
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
BufferedImage getImageStream(String filePath) {
File imageFile
BufferedImage bufferedImage
try {
imageFile = new File(filePath);
bufferedImage = ImageIO.read(imageFile)
} catch(Exception ex) {
ex.printStackTrace();
}
return bufferedImage
}
why not try to store the img file in a folder and save the url to the database?
Have you thought about this?
<img src="<s:url value="/images/sun.jpg"/>" />
Hope this will help
:)