lt.monarch.chart.servlet
Class ImageServlet

java.lang.Object
  extended by HttpServlet
      extended by lt.monarch.chart.servlet.ImageServlet
Direct Known Subclasses:
ChartServlet

public abstract class ImageServlet
extends HttpServlet

Image encoding servlet. Every HTTP request triggers the createImage method. The returned image is then encoded and returned to the browser.


Field Summary
Modifier and Type Field and Description
protected  AbstractEncoder encoder
          encoder used for image encoding
 
Constructor Summary
Constructor and Description
ImageServlet()
           
 
Method Summary
Modifier and Type Method and Description
protected abstract  java.awt.Image createImage(HttpServletRequest req)
          Requests an image to be created for the HTTP request.
 void doGet(HttpServletRequest req, HttpServletResponse res)
          Called by the server to allow a servlet to handle a GET request.
protected  AbstractEncoder getEncoder()
          Returns an encoder used to encode image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encoder

protected AbstractEncoder encoder
encoder used for image encoding

Constructor Detail

ImageServlet

public ImageServlet()
Method Detail

createImage

protected abstract java.awt.Image createImage(HttpServletRequest req)
                                       throws ServletException
Requests an image to be created for the HTTP request.

Parameters:
req - servlet request
Returns:
image to be returned to the browser
Throws:
ServletException - if the request for the GET could not be handled

getEncoder

protected AbstractEncoder getEncoder()
Returns an encoder used to encode image. The default implementation returns an instance of lt.monarch.image.png.PNGEncoder. To use other encoder you should override this method so that it would return instance of required encoder.

Returns:
encoder used to encode image

doGet

public final void doGet(HttpServletRequest req,
                        HttpServletResponse res)
                 throws ServletException,
                        java.io.IOException
Called by the server to allow a servlet to handle a GET request. Triggers the createImage method. The returned image is then encoded and returned to the browser.

Parameters:
req - an HttpServletRequest object that contains the request the client has made of the servlet
res - an HttpServletResponse object that contains the response the servlet sends to the client
Throws:
ServletException - if the request for the GET could not be handled
java.io.IOException - if an input or output error is detected when the servlet handles the GET request