RE: Cookie creation bug (?) for servlet-including jsp files

2001-03-27 Thread Mike Cannon-Brookes

Sounds like the flush=true is committing the response stream before you add
teh cookie. This is not a bug.

You have to add cookies before ANY part of the response is sent to the
browser.

-mike

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of Ostroff, Mike
 Sent: Wednesday, March 28, 2001 7:03 AM
 To: Orion-Interest
 Subject: Cookie creation bug (?) for servlet-including jsp files


 I am working on a web-app (powered by Orion 1.4.5) that uses a jsp page
 with several Java servlets included within it that do the more complex
 computations. The jsp file has lines like:
 "jsp:include page="/servlet/ExampleServlet" flush="true" /" that load
 the servlets. This does a request on the servlet and inserts the HTML
 they return at the include point.

 The problem is that in one of the servlets I am trying to create some
 cookies using the standard HttpServletResponse.addCookie(new
 Cookie(name, val)) code. If I run the servlet directly without embedding
 it in a jsp file then the cookies get created just fine. But when I try
 to execute the servlet from within the jsp file, then the cookies do not
 get created, even though I know that the addCookie() method is being
 reached and executed. This same jsp and servlet combination worked and
 created the cookies without problems when run under Allaire's JRun 2.3.
 Is this an Orion bug? And can anyone think of a work around that won't
 involve massive changes to how the code is organized?

  - Mike







Re: Cookie creation bug (?) for servlet-including jsp files

2001-03-27 Thread Trevor Squires

On Tue, 27 Mar 2001, Ostroff, Mike wrote:

 I am working on a web-app (powered by Orion 1.4.5) that uses a jsp page
 with several Java servlets included within it that do the more complex
 computations. The jsp file has lines like: 
 "jsp:include page="/servlet/ExampleServlet" flush="true" /" that load
 the servlets. This does a request on the servlet and inserts the HTML
 they return at the include point.
 
 The problem is that in one of the servlets I am trying to create some
 cookies using the standard HttpServletResponse.addCookie(new
 Cookie(name, val)) code. If I run the servlet directly without embedding

do you think this might have something to do with the output of the JSP
being committed (and thus the HTTP headers already being sent) by the time
you do the jsp include of your servlet?

 it in a jsp file then the cookies get created just fine. But when I try
 to execute the servlet from within the jsp file, then the cookies do not
 get created, even though I know that the addCookie() method is being
 reached and executed. This same jsp and servlet combination worked and
 created the cookies without problems when run under Allaire's JRun 2.3.

perhaps JRUN has a bigger output buffer for jsp's than orion?

Trevor

 Is this an Orion bug? And can anyone think of a work around that won't
 involve massive changes to how the code is organized?
 
  - Mike