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
Solved

tomcat and outputting a GIF

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 65
How do I remove an object from a 3 40
JavaFX TableView not displaying correctly 3 56
Is Applet the way to go for my drag and drop system? 8 25
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

860 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