package jp.ossc.petstore.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * ログアウトアクション
 * @author ossc
 * @version $Revision: 1.2 $
 */
public class LogoutAction extends BaseAction {

    /**
     * ログアウトアクション実行。<br>
     * セッションを無効化する。
	 * @param mapping ActionMapping
	 * @param form ActionForm
	 * @param request HTTPリクエスト
	 * @param response HTTPレスポンス
	 * @return 画面遷移先
	 * @throws Exception Action実行時エラー
     */
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {
        
        HttpSession session = request.getSession(false);
        if (session != null) {
            session.invalidate();
            session = null;
        }
        
        return mapping.findForward("success");
    }

}
