package sample.ac;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class SessionJspAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
// ユーザーデータの設定
UserData data = new UserData();
data.setUserId("usr01");
data.setUserName("name");
//セッションを取得
HttpSession session = request.getSession();
//UserDataデータをsessionスコープで保存
session.setAttribute("userData", data);
return mapping.findForward("success");
}
}
|