Solved

tomcat and outputting a GIF

Posted on 2006-07-21
3
306 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB Script to add site to Java Exception List 4 73
Windows 10 IE Certificate Issue 10 45
javap not working 8 43
eclipse console opening separately 2 16
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

816 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now