com.pureinfo.tgirls.servlet.CookieTestServlet.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.tgirls.servlet.CookieTestServlet.java

Source

/**
 * PureInfo TGirls
 * @(#)CookieTestServlet.java   1.0 2009-4-7
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.tgirls.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;

import com.pureinfo.ark.ArkHelper;
import com.pureinfo.ark.content.ArkContentHelper;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.tgirls.domain.IUserMgr;
import com.pureinfo.tgirls.model.User;

public class CookieTestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest _req, HttpServletResponse _resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        this.doGet(_req, _resp);
    }

    @Override
    protected void doPost(HttpServletRequest _req, HttpServletResponse _resp) throws ServletException, IOException {
        try {
            String userId = _req.getParameter("id");
            if (StringUtils.isEmpty(userId)) {
                userId = "1";
            }

            IUserMgr mgr = (IUserMgr) ArkContentHelper.getContentMgrOf(User.class);
            User u = mgr.getUserByTaobaoId(userId);

            _req.getSession().setAttribute(ArkHelper.ATTR_LOGIN_USER, u);
            Cookie c = new Cookie("", "");

            //            _req.getCookies()[0].
        } catch (PureException e) {
            // TODO Auto-generated catch block
            e.printStackTrace(System.err);
        }
    }

}