|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.hd.d.pg2k.webSvr.bgImg.BgImageServlet
public final class BgImageServlet
Servlet to serve dynamic and partially-random HTML-page background image. This serves a randomly-generated image which we would like to be slightly different for each visitor.
This is intended to be pleasing on the eye, and possible, if required, to read normal black text over. So the image is nearly white with a slowly changing 'watermark' image.
To minimise bandwidth fetching this, and CPU time generating it, this is designed to be served with the "caching" filter in front of it, so that any one user should typically only fetch a new image once per week or thereabouts, though each user should get a different one. Also, the image dimensions and quality are adjusted to those of a "standard" thumbnail, which does not take you lots of space in memory or on the wire.
We may cache the last image generated, so that if the system is busy the last image may be returned again rather than a new one being generated.
| Field Summary | |
|---|---|
private static byte[][] |
_imageCache
Simple cache by "seed" value of background images as raw byte[]; each entry is computed on demand. |
private static java.lang.Object |
_imageCacheLock
Lock for access to _imageCache. |
private static long |
creationTime
Construction time for this class. |
private static int |
MIN_BGS
Minimum number of different backgrounds seen; strictly positive. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
| Constructor Summary | |
|---|---|
BgImageServlet()
|
|
| Method Summary | |
|---|---|
void |
doAction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Respond to a GET/HEAD request for the content served by this servlet. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Respond to a GET request for the content served by this servlet. |
void |
doHead(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Respond to a HEAD request for the content served by this servlet. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long creationTime
private static final int MIN_BGS
As this value gets larger, memory consumption will go up.
We set this not to use more than about 1%--2% of total memory, although we may find an abnormally-small heap size during startup when this will get computed.
private static final byte[][] _imageCache
The size of this array determines how many different images we hold, and more will use more memory.
Access the array contents only under the _imageCacheLock.
We vary the size of this array a little on each run to vary the mix. The array size stays constant while the class remains loaded.
private static final java.lang.Object _imageCacheLock
private static final long serialVersionUID
| Constructor Detail |
|---|
public BgImageServlet()
| Method Detail |
|---|
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException
doGet in class javax.servlet.http.HttpServletrequest - The servlet request we are processingresponse - The servlet response we are producing
java.io.IOException - if an input/output error occurs
public void doHead(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException
doHead in class javax.servlet.http.HttpServletrequest - The servlet request we are processingresponse - The servlet response we are producing
java.io.IOException - if an input/output error occurs
public void doAction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException
request - The servlet request we are processingresponse - The servlet response we are producing
java.io.IOException - if an input/output error occurs
|
DHD Multimedia Gallery V1.53.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||