Nick McKenna wrote:
>
> Dear All
>
> I can't get iPlanet to create an instance of the class Image. I am trying to
> create a servlet that outputs a gif (ACME encoder) image.
>
> The code is:
>
> // Create the image
> Frame dummy = new Frame();
> image = dummy.createImage(width, height);
>
> The Frame constructor returns a null pointer which causes the
> dummy.createImage line to throw a null pointer exception.
The image is served in a second request (i.e. when the browser sees <img
src=foobar.gif> a new request is made to the server.) You can't use
frames unless you use an applet. The way to do this is to create a
servlet that sever the request for the image:
<img src="FooBarImageServlet">
In this image be sure to set the content type to image/gif or image/jpeg
and stream the image to the browser as a BufferedOutputStream:
BufferedOutputStream out = new
BufferedOutputStream(response.getOutputStream());
response.setContentType(rs.getString(2));
try{
int BytesRead;
byte[] buf = new byte[400000];
InputStream dbin = rs.getBinaryStream(1);
while (((BytesRead=dbin.read(buf)) != -1)){
out.write(buf,0,BytesRead);
out.write(BytesRead);
}
out.flush();
sven
--
======================================================================================
Sven van 't Veer http://www.cachoeiro.net
Java Developer [EMAIL PROTECTED]
_/_
The answer / \
to the ultimate question nnn|.
.|nnn 42
=========================================U============================================
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html