Hello everyone, i have the following code in a jsp file, i want to set a
cookie to remember the loginname and the checkbox value, if the checkbox
value is null (is not checked) i want to kill/destroy the cookie... if it's
not null i want it to set the cookies...
when i use the following line without the last jsp:forward tag, it works
fine, if i use jsp:frward tag, it doesn't work, it always remembers the
cookie, it doesn't destroy it...
any suggestion from you guys...
also what is the best way to bestroy a cookie, is there a method, or you
just setMaxAge to zero...
Thank you.
<%
String loginName = request.getParameter ("txtLoginName");
String remember = request.getParameter ("chkRemember");
Cookie oneCookie = null;
if (remember == null ) {
oneCookie = new Cookie("Login", "");
oneCookie.setMaxAge(0);
oneCookie.setPath("/");
response.addCookie(oneCookie);
oneCookie = new Cookie("Remember", "");
oneCookie.setMaxAge(0);
oneCookie.setPath("/");
response.addCookie(oneCookie);
}
else if (remember.equals("Remember")) {
oneCookie = new Cookie("Login", loginName);
oneCookie.setMaxAge(10000);
oneCookie.setPath("/");
response.addCookie(oneCookie);
oneCookie = new Cookie("Remember", remember);
oneCookie.setMaxAge(10000);
oneCookie.setPath("/");
response.addCookie(oneCookie);
}
%>
<%--<jsp:forward page="Main.jsp" />--%>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets