0
的login.html註銷
<form method="get" action="NewServlet">
name: <input type="text" name="user">
<br>
pass: <input type="password" name="password">
<br>
<input type="submit">
</form>
NewServlet
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String s = request.getParameter("user");
String pass = request.getParameter("password");
UserBean bean=new UserBean();
bean.setLogin(request.getParameter("user"));
bean.setPassword(request.getParameter("password"));
if(bean.getLogin().equals("admin")&&bean.getPassword().equals("prerna"))
{
HttpSession session=request.getSession(true);
request.setAttribute("user",bean);
session.setAttribute("user",request);
RequestDispatcher rd=request.getRequestDispatcher("/show.jsp");
rd.forward(request,response);
}
else
{
response.sendError(404, "invalid usename or password");
// response.sendRedirect("http://www.google.com");
out.print("<H1>ERROR</H1>");
}
loginout.jsp
<%
session.invalidate();
response.sendRedirect("login.jsp");
%>
後,當我點擊後退按鈕我以前的頁面獲取顯示,我不想防止回到前一頁。 任何人都可以建議我對於這個問題
重複的http://stackoverflow.com/questions/4194207/restrict-user-from-the-previous -page-後signout,http://stackoverflow.com/questions/2249888/how-to-handle-back-browser-button-problem-using-spring,http://stackoverflow.com/questions/3341824/handling瀏覽器後退按鈕在jsp等 – BalusC 2011-02-17 16:58:19