1// Java side
2BufferedImage image = ImageIO.read(new File("helloworld.png"));
3ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
4ImageIO.write(image, "png", outputStream);
5String encodedImage = Base64.encode(outputStream.toByteArray());
6
7// js side
8<img src="data:image/png;base64,[ENCODED STRING GOES HERE]">