ログインフォームがあるWebサイトがあります。ログインが成功した場合、オブジェクトユーザーをセッションに入れ、次のように別のページ(セッション属性が必要)に移動します。
-Javaサーブレット-
request.getSession(true).setAttribute("utente", u);
request.getSession(true).setAttribute("abbonamento", a);
request.getRequestDispatcher("HomeUtente.jsp").forward(request, response);
-Jspページ-
<%
Utente u = null;
Abbonamento a = null;
try {
u = (Utente) session.getAttribute("utente");
a = (Abbonamento) session.getAttribute("abbonamento");
} catch (Exception e) {
a = null;
u = null;
e.printStackTrace();
}
%>
さて、一度これを行うと問題ありませんが、ページを更新するとセッションが削除されるようです。
これは、ページを(デバッグモードで)更新すると、aとuの両方がnullになるためだと思います。
何か案が?