FileDocCategorySizeDatePackage
AjaxResponseServlet.javaAPI DocExample1306Sun Apr 23 08:24:54 BST 2006com.oreilly.ajax.servlet

AjaxResponseServlet

public class AjaxResponseServlet extends HttpServlet

Fields Summary
private static final long
serialVersionUID
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)


	     
               

        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("?");
        }