Solved

How do I display an image using a Java Servlet?

Posted on 2009-04-14
2
304 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
ID: 24143841
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
ID: 31570176
Of course. Thank you.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parentbit challenge 3 101
where is session ID cache stored 1 51
Where to store the queries for modification of table 4 61
HSSFWorkbook cannot be resolved error 10 67
Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
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.

785 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