String key = req.getParameter("key");
if (key != null) {
// extract the first character from key
int keyInt = key.charAt(0);
String decimalString = Integer.toString(keyInt);
// setup the response
res.setContentType("text/xml");
res.setHeader("Cache-Control", "no-cache");
// write out the response string
res.getWriter().write(decimalString);
}
else {
// If key comes back as a null, return a question mark.
res.setContentType("text/xml");
res.setHeader("Cache-Control", "no-cache");
res.getWriter().write("?");
}