// used to create a unique key
// Get an Image
String imageFile = req.getRealPath("/system/images/serverduke.gif");
Image image = Toolkit.getDefaultToolkit().getImage(imageFile);
// Create a unique key under which to store the image
String key = "com.oreilly.servlet.ChainImageSource." + keynum++;
// Store the image in the system Properties list using that key
System.getProperties().put(key, image);
// Tell the next servlet to expect an image key
res.setContentType("java-internal/image-key");
PrintWriter out = res.getWriter();
// Send the key
out.println(key);