Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

tomcat and outputting a GIF

Posted on 2006-07-21
3
Medium Priority
?
343 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 1000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 …
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

670 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