• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Image Servlets

 
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)

{
try
{
res.setContentType("image/gif");
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 = br.read(cbuf, 0, 1023)) > 0)
{
bw.write(cbuf,0,len);
}
bw.flush();
bw.close();
}

catch(Exception e)

{
System.out.println("Problem rendering image" + e);
}
}
 
Get me the mayor's office! I need to tell her about this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic