Solved

How do I display an image using a Java Servlet?

Posted on 2009-04-14
2
301 Views
Last Modified: 2013-12-02
When I try to return an image in a servlet.java file using:
out.println("<img src="+ layer + "/");
I can see that the correct size of the images is being sent to the page but the image does not appear. I'm using a BufferedImage:
BufferedImage layer = ImageIO.read(new File("/documents/images/test.png"));
What am I doing wrong?
0
Comment
Question by:DG1212
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
your servlet needs to return the contents of the image. You use a img tag to *call* your servlet

http://www.exampledepot.com/egs/javax.servlet/GetImage.html

0
 

Author Closing Comment

by:DG1212
Comment Utility
Of course. Thank you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now