nkalagarla@gmail.com wrote:
How are you accessing this jsp from the browser? Try specifying the
fully qualified host name for the test server(yourServerName.cuny.edu)
for accessing the jsp.
Yes, thats what I'm doing. Actually, although my example shows a
setMaxAge, I don't really want anything more than a session cookie. But
not having it there didn't make a difference either. I had used the
HTML <SCRIPT> tag at first, but then I had trouble expiring the cookie
later on, and then even just changing its value - I couldn't change it
using the <SCRIPT> tag. :-( But I learned that the reason for that
turned out to be the redirect method I was used (see below). So I
commented that out and used Javascript to do the redirect, but I'm not
happy doing things both ways. I just wanted to replace the <SCRIPT> tag
with the previous java code and go back to using the Redirect
statements you see below with java doing the expire and not use
Javascript. Thanks for taking the time to respond, appreciated.
String url = "blah.blah.cuny.edu";
//Get the Cookie from the HTTP Request Headers
Cookie info = null;
Cookie[] cookies = request.getCookies();
for (int i=0; i < cookies.length; i++) {
info = cookies[i];
String cookiename= info.getName();
if (cookiename.equals("USERROLE")) {
if (info.getValue().equals("Visitor")) {
// Change the cookie values to NULL now that we are
done and then redirect
%>
<SCRIPT
LANGUAGE="JavaScript">document.cookie='APPLYONLINE=NULL; path=/;
domain=.cuny.edu;'</SCRIPT>
<SCRIPT
LANGUAGE="JavaScript">document.cookie='USERROLE=NULL; path=/;
domain=.cuny.edu;'</SCRIPT>
<SCRIPT
LANGUAGE="JavaScript">window.location.replace("<%=url%>");</SCRIPT>
<%
// info.setMaxAge(0);
// info.setPath("/");
// response.addCookie(info);
// RedirectUtils rdu = new RedirectUtils();
// rdu.sendRedirect(request, response, url);
}
}
}
If you're storing session data, would it not be better to store in in the HttpSession object, Session within the jsp page ?