public abstract class ImageServlet extends ParameterizedServlet
This servlet returns a response that contains the binary data of an image (JPEG or PNG) that can be viewed in a web browser.
The navigation map servlet takes the following parameters (any applicable defaults are in bold and required parameters are in italics):
| key | value |
|---|---|
| imageFormat | (png | jpeg) |
| imageWidth | <integer (700)> |
| imageHeight | <integer (350)> |
| Modifier and Type | Field and Description |
|---|---|
static String |
IMAGE_FORMAT_JPEG
Request parameter value representing a JPEG image.
|
static String |
IMAGE_FORMAT_PARAM
Request parameter for image format.
|
static String |
IMAGE_FORMAT_PNG
Request parameter value representing a PNG image.
|
static int |
IMAGE_HEIGHT_DEFAULT
Default image height.
|
static String |
IMAGE_HEIGHT_PARAM
Request parameter for image height.
|
static int |
IMAGE_WIDTH_DEFAULT
Default image width.
|
static String |
IMAGE_WIDTH_PARAM
Request parameter for image width.
|
| Constructor and Description |
|---|
ImageServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Object |
createImage(javax.servlet.http.HttpServletRequest request)
Create the image being rendered.
|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected String |
getDefaultImageFormat()
Return the default
imageFormat. |
protected int |
getDefaultImageHeight()
Return the default
imageHeight. |
protected int |
getDefaultImageWidth()
Return the default
imageWidth. |
protected String |
getImageFormat()
Return the image format.
|
protected int |
getImageHeight()
Return the image height.
|
protected int |
getImageWidth()
Return the image width.
|
void |
init() |
protected void |
parseParameters(javax.servlet.http.HttpServletRequest request)
This method will be called automatically by the ImageServlet.
|
protected abstract void |
renderJpegImage(javax.servlet.ServletOutputStream out,
Object imgObj)
Render a JPEG version of the image into the output stream.
|
protected abstract void |
renderPngImage(javax.servlet.ServletOutputStream out,
Object imgObj)
Render a PNG version of the image into the output stream.
|
invalidParamErr, invalidParamErr, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, parseBooleanParameter, parseDoubleParameter, parseEnumParameter, parseIntParameter, parseLongParameter, parseRequiredBooleanParameter, parseRequiredDoubleParameter, parseRequiredIntParameter, parseRequiredLongParameter, parseRequiredStringParameter, parseRequiredStringParameter, parseStringParameter, parseStringParameter, requiredParamErrdoDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, servicepublic static final String IMAGE_FORMAT_PARAM
public static final String IMAGE_FORMAT_PNG
public static final String IMAGE_FORMAT_JPEG
public static final String IMAGE_WIDTH_PARAM
public static final int IMAGE_WIDTH_DEFAULT
public static final String IMAGE_HEIGHT_PARAM
public static final int IMAGE_HEIGHT_DEFAULT
public void init()
init in class javax.servlet.GenericServletpublic void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionprotected abstract Object createImage(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
request - the servlet requestjavax.servlet.ServletExceptionprotected abstract void renderPngImage(javax.servlet.ServletOutputStream out,
Object imgObj)
throws IOException
out - the output streamIOExceptionprotected abstract void renderJpegImage(javax.servlet.ServletOutputStream out,
Object imgObj)
throws IOException
out - the output streamIOExceptionprotected void parseParameters(javax.servlet.http.HttpServletRequest request)
request - the HTTP request objectprotected String getImageFormat()
IMAGE_FORMAT_PNG or IMAGE_FORMAT_JPEGprotected int getImageHeight()
{@link IMAGE_HEIGHT_DEFAULT}protected int getImageWidth()
{@link IMAGE_WIDTH_DEFAULT}protected String getDefaultImageFormat()
imageFormat.protected int getDefaultImageWidth()
imageWidth.protected int getDefaultImageHeight()
imageHeight.Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.