Solved

tomcat and outputting a GIF

Posted on 2006-07-21
3
320 Views
Last Modified: 2013-11-24
Hi,

I have a servlet that i would like to use to output images.

The problem is, when I output the image as a string, it doesnt render ('The image 'http://.../' cannot be displayed because it contains errors).

If i also send the image to a file, I get a renderable image.

This is the code that I am trying to use with no luck:
   response.setContentType("image/gif");
   PrintWriter out = response.getWriter();
   out.println(new String[]{image});

where image is a byte[]. If i look at the source for the page, I actually see the textual representation of the gif.

Any ideas of how to get this to display properly?

Thanks.
0
Comment
Question by:kawas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 17157525
You need to do

response.setContentType("image/gif");
OutputStream out = response.getOutputStream();

and write the image to that
0
 
LVL 13

Author Comment

by:kawas
ID: 17157541
thanks a lot.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17157543
:-)
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question