BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

weblogic.html
Class ImagePage

java.lang.Object
  |
  +--weblogic.html.WebPage
        |
        +--weblogic.html.ImagePage

public class ImagePage
extends WebPage

An ImagePage is used to display an image stored as an array of bytes (binary large object). Its imagetype is "gif" or "jpeg", and its image data is the image. Technically, an ImagePage creates an HTTP request for a certain type of image.

Using dbKona, you can retrieve image files from a database and display them on a page. A servlet example is shown here:

 
 public abstract void service(ServletRequest req, ServletResponse res) 
   throws ServletException, IOException {
   try {
     String iname  = req.getParameter("imagename");

TableDataSet td = new TableDataSet(conn, "imagetable"); td.selectStmt().setQbe("name", iname); td.fetchRecords();

Record rec = td.getRecord(0);

// Retrieve the images from the database ImagePage hp = new ImagePage(rec.getValue("type").asString(), rec.getValue("data").asBytes()); hp.output(resp.getOutputStream()); } catch (Exception e) { throw new ServletException(e.toString()); } }

You can use ImagePage to write a servlet that retrieves images from a database for display on your htmlKona pages. Use the constructors in this class that are designed for servlets. Then write and compile the class and add it to your Java-enabled server configuration (for example, with a Jeeves server, you'll add a line for the class to your servlet.properties file). When you compose your HtmlPage, add an ImageElement to it that requests that servlet. For example, if your Jeeves servlet is named imageDBGet:
  hp.getBody()
    .addElement(new ImageElement("http://jeeves_server/servlet/imageDBGet");

Version:
2.1
Author:
Copyright (c) 1995-96, WebLogic, Inc.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.
See Also:
ImageElement

Fields inherited from class weblogic.html.WebPage
allow, codeset, contentbuf, contentencoding, contentlength, contents, contenttype, expires, lastmodified, location, pragma, referer, server
 
Constructor Summary
ImagePage(byte[] image)
          Constructor used with servlets.
ImagePage(java.lang.String imagefile)
          Constructor used with servlets.
ImagePage(java.lang.String imagetype, byte[] image)
          Constructs an ImagePage of the specified content-type with the specified image data.
ImagePage(java.lang.String imagetype, java.lang.String imagefile)
          Constructs an ImagePage of the specified content-type with the specified image file.
 
Method Summary
 void output(java.io.OutputStream ostr)
          Outputs the file.
 
Methods inherited from class weblogic.html.WebPage
allow, allow, contentBuf, contentBuf, contentEncoding, contentEncoding, contentLength, contentLength, contents, contents, contentType, contentType, expires, expires, includeHeader, lastModified, lastModified, location, location, output, output, output, pragma, pragma, referer, referer, server, server, setClientPull, setClientPull, setCodeset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImagePage

public ImagePage(java.lang.String imagetype,
                 byte[] image)
Constructs an ImagePage of the specified content-type with the specified image data.

Parameters:
imagetype - GIF or JPG or other browser-viewable image type
image - byte[] of image data

ImagePage

public ImagePage(java.lang.String imagetype,
                 java.lang.String imagefile)
          throws java.io.IOException
Constructs an ImagePage of the specified content-type with the specified image file.

Parameters:
imagetype - GIF or JPG or other browser-viewable image type
imagefile - Path and name of image file
Throws:
java.io.IOException - if there is an error opening or reading the file

ImagePage

public ImagePage(byte[] image)
Constructor used with servlets. Content type is sent from servlet.

Parameters:
image - byte[] of image data

ImagePage

public ImagePage(java.lang.String imagefile)
          throws java.io.IOException
Constructor used with servlets. Content type is sent from servlet.

Parameters:
image - String image filename
Method Detail

output

public void output(java.io.OutputStream ostr)
            throws java.io.IOException
Outputs the file.

Overrides:
output in class WebPage

Documentation is available at
http://www.weblogic.com/docs51