Solved

How do I display an image using a Java Servlet?

Posted on 2009-04-14
2
309 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 83
eclipse compiler vs Installed JREs option 3 107
Spring Framework HTTPSession management 1 45
Glassfish admin console not working 1 36
Verbose logging is used to diagnose garbage collector problems. By default, -verbose:gc output is written to either native_stderr.log or native_stdout.log.   It is also possible to redirect the logs to a user-specified file. This article will de…
This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
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.

821 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