public int doStartTag() throws JspException  {
		OutputStream os = null;
		ImageOutputStream ios = null;
		try {
			try {
				JspWriter out = pageContext.getOut();
				if (text == null) {
					out.println("<b>Error: text not set");
				}

				ServletContext application = pageContext.getServletContext();
				File fileForDir = new File(application.getRealPath(imgDir));
				if (!notifiedDirPath) {
					System.out.println("Temp dir is " + fileForDir.getAbsolutePath());
					notifiedDirPath = true;
				}
				File file = File.createTempFile("img", ".jpg", fileForDir);

				// XXX use fontMetrics to size the rectangle

				// Create an Image
				BufferedImage img =
					new BufferedImage(W, H,
							BufferedImage.TYPE_INT_RGB);

				// Get the Image's Graphics, and draw.
				Graphics2D g = img.createGraphics();

				g.setColor(Color.white);
				g.fillRect(0,0, W, H);
				g.setColor(Color.green);

				g.drawString(text, 10, 20);

				// Write the output
				System.out.println(
						"TextImageTag.doStartTag(): Creating output file " + file);
				os = new FileOutputStream(file);
				ios = ImageIO.createImageOutputStream(os);

				if (!ImageIO.write(img, "jpeg", ios)) {
					throw new IOException("Failed to write JPEG to " + file);
				}

				out.println("<img src='" + imgDir + "/" + file.getName() + "' alt='text image'/>");
				out.flush();
			} finally {
				if (ios != null)
					ios.close();
				if (os != null)
					os.close();
			}
		} catch (IOException ex) {
			System.err.println("TextImageServleg.doStartTag: caught " + ex);
		}
		return EVAL_BODY_INCLUDE;
	}