FileDocCategorySizeDatePackage
AjaxLoginServlet.javaAPI DocExample1455Wed Apr 05 20:05:26 BST 2006com.oreilly.ajax.servlet

AjaxLoginServlet

public class AjaxLoginServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

      res.setContentType("text/xml");
      res.setHeader("Cache-Control", "no-cache");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        if (username != null && password != null)
        {
        	User user = UserManager.login(username,password);
            if (user!=null)
            {
                String responseString = ShoppingCartManager.getJSONShoppingCart(user);
            	HttpSession session = req.getSession();
            	session.setAttribute("user",user);
                res.getWriter().write(responseString);
            }
            else
              res.getWriter().write("fail");
        } 
        else
          res.getWriter().write("fail");