This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Image Servlets  RSS feed

Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code that writes Images to a screen, but the images come up looking really bad. There must be a mistake in my code, see anything?

private void GIF(String f, HttpServletResponse res)

OutputStream out = res.getOutputStream();
System.out.println("################" + res.getOutputStream());

BufferedReader br = new BufferedReader(new FileReader(f));

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));

char[] cbuf = new char[1024]; // read/write 1024 bytes at a time..
int len;

while ((len =, 0, 1023)) > 0)

catch(Exception e)

System.out.println("Problem rendering image" + e);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!