| Author |
Display images and text
|
Adnan Badar
Greenhorn
Joined: May 07, 2003
Posts: 6
|
|
Hello All, I have to display jpg files placed in some real path(not in web context). Along with images i also have to display header and footer text. I am unable to display both images and text together. I am using this code: public void doGet() { response.setContentType("text/html"); File f = new File("D:\\ImageArchive\\file1.jpg"); com.sun.image.codec.jpeg.JPEGImageDecoder decoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(new FileInputStream(f)); java.awt.image.BufferedImage image =decoder.decodeAsBufferedImage() ; javax.servlet.ServletOutputStream sos = response.getOutputStream(); com.sun.image.codec.jpeg.JPEGImageEncoder encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(sos); encoder.encode(image); } Thanks in advance....
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56162
|
|
I don't see anywhere in your code where you actually write to the response, but in any case, no, you cannot mix images and text. What you CAN do, is to generated HTML with text and image tags that reference the image. To serve images that cannot be addressed via URL, I'd write a servlet that can read and serve the image (and only the image) and reference that in the src attribute of your image tags. hth, bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Display images and text
|
|
|