tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fedor Karpelevitch <fe...@simpata.com>
Subject RE: No application cookies are getting sent to browser (Redirect drops cookies)
Date Fri, 05 May 2000 20:13:29 GMT
I believe that's just correct behavior for redirect to clear any other
header info (including cookies)

WBR, Fedor.
 
Today: Errare humanum est.
 
 


> -----Original Message-----
> From: Dunkle, Ed [mailto:Ed.Dunkle@ameriserve.com]
> Sent: Thursday, May 04, 2000 3:04 PM
> To: 'tomcat-user@jakarta.apache.org'
> Subject: RE: No application cookies are getting sent to browser
> (Redirect drops cookies)
> 
> 
> OK, this is the same behavior we get with WebShpere 2.0  (3.2 may be
> fixed...)
> If you set the cookie in the ContentType and then redirect, 
> the cookies
> never get sent to the client:
> 
> 	response.setContentType("text/html\nSet-Cookie: hot.name=" +
> userName + "; path=/; expires=" + cookieDate + "\nSet-Cookie: 
> hot.regnum=" +
> registrationNumber + "; path=/; expires=" + cookieDate);
> 	response.sendRedirect(somePage);
> 
> So I have to redirect by sending output like this:
> 	ServletOutputStream p = response.getOutputStream();
> 	p.println("<HTML><HEAD>");
> 	p.println("<meta http-equiv=\"REFRESH\" content=\"0; URL=" +
> somePage + "\">");
> 	p.println("</HEAD></HTML>");
> 	p.flush();
> 	p.close();
> 
> Is this behavior dictated by the spec?  I noticed it requires 
> the buffer to
> be cleared when sendRedirect() is called.
> 
> Thanks,
> Ed
> 
> 
> -----Original Message-----
> From: Dunkle, Ed 
> Sent: Thursday, May 04, 2000 2:10 PM
> To: 'tomcat-user@jakarta.apache.org'
> Subject: No application cookies are getting sent to browser
> 
> 
> Is there some configuration setting to activate application 
> level cookies?
> 
> I have servlet code that works in WebSphere (and I believe it 
> used to work
> in Apache/JServ but we don't use that anymore) for writing 
> cookies.  Under
> Tomcat (with IIS if that matters) I get a JSession cookie but 
> it doesn't
> even try to send my application cookies.
> 
> Any ideas?
> 
> 
> Here's the code:
> 
> public void writeCookies(HttpServletResponse response, String 
> userName,
> String registrationNumber, Date expiryDate) {
> 	Calendar expiry = 
> Calendar.getInstance(TimeZone.getTimeZone("GMT"));
> 	expiry.setTime(expiryDate);
> 	DateFormat df = DateFormat.getDateTimeInstance();
> 	SimpleDateFormat sdf = null;
> 	String cookieDate = null;
> 		
> 	try {
> 		sdf = (SimpleDateFormat) df;
> 		sdf.setCalendar(expiry);
> 		sdf.applyPattern("EEE, dd-MMM-yyyy hh:mm:ss zzz");
> 		cookieDate = sdf.format(expiry.getTime());
> 	} catch (ClassCastException cce) {
> 		cce.printStackTrace();
> 	}
> 	
> 	response.setContentType("text/html\nSet-Cookie: hot.name=" +
> userName + "; path=/; expires=" + cookieDate + "\nSet-Cookie: 
> hot.regnum=" +
> registrationNumber + "; path=/; expires=" + cookieDate);
> }
> 
> --------------------------------------------------------------
> ------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
> 

Mime
View raw message