When ever you use forward tag ensure that the forward is done before any
response is sent to the client using the response object.
this seems to be the problem in your case, as this response never
reaches the
client.
cheers
Sivarajagopal
-----Original Message-----
From: Sebouh [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 06, 2001 3:12 PM
To: [EMAIL PROTECTED]
Subject: Cookie problem
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
===========================================================================
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