I'm building a web-site using Java Spring and Hibernate and using Tomcat 7 as server. I have a page of this site where, once the user clicks on an image other two images are loaded. The workflow is the following:
Image Clicked -> Calculation(spring method) -> Images saved on the server as jpg -> Images updated from the server and showed to the client.
The images are loaded like follows:
response.setContentType("image/jpg");
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(xzCrossUrl);
int size = in.available();
byte[] content = new byte[size];
in.read(content);
out.write(content);
in.close();
out.close();
I know this probably is not the best way to doing it, but I have not much experience yet.
Locally it works fine, but when I put the .war on the tomcat directory and connect to the server, a Java outOfMemory heap space problem is coming out, and the images are loaded much slower than locally.
I tried to increase the memory used by tomcat but it seems not to work; maybe I'm doing something wrong.
Can you please help me with this?
Thank you very much in advance!