Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Tomcat and cookies caching issue

Riccardo

2007-07-26

Replies:

On 7/26/07, Rainer Jung <rainer.jung@(protected):
> Hi Riccardo,
>
> if I understood your description correct, your Tomcat server itself
> communicates with another backend to get the report. In this sentence it
> is important, that Tomcat and not the browser talks to this backend.

You are right, when the request to run the report hits Tomcat, this
will send a request to a remote webserver where the report is built.
Between Tomcat and the remote server sits Apache httpd proxy
translating the url of the request with rules like

ProxyPass /reports/ http://x.y.z.w/reporting/
ProxyPassReverse /reports/ http://x.y.z.w/reporting/

> I expect that you do this via HTTP as well.

Correct.

> Note that there is no HTTP
> client contained in Tomcat. Your webap must have an HTTP client bundled,
> which the app uses to talk to the other server. This client might well
> have some sort of cookie handling implemented, and it's the
> responsibility of the using webapp to correctly use and configure the
> HTTP client it bundled.

I'm not sure what you mean, in my case the external pages sourced from
the remote webserver are embedded into my webapp via an IFrame. In
these pages there's a form with the reports parameteres field, and
this form is submitted to the remote server to generate the report.

I started recently to work on this project, and honestly sometimes I'm
a bit confused about the route of the requests, but I believe that
when I submit a request to generate a report from the remote webserver
the path is: browser -> apache proxy -> tomcat -> apache proxy ->
remote webserver -> apache proxy -> tomcat -> apache proxy -> browser.

Maybe I should define some headers management rule within the webapp..
I haven't measured the time exactly, but i find quite interesting that
this caching effect lasts around 2 minutes, than disappears. I wonder
if it would be possible to set this time to 0 through some
parameter...


Thanks so much for your time
Riccardo



>
> But I might have misunderstood you.
>
> Regards,
>
> Rainer
>
> Riccardo wrote:
> > On 7/26/07, Len Popp <len.popp@(protected):
> >> I don't think Tomcat caches cookie values. I could be wrong about
> >> this, but it seems to me that Tomcat just gets the cookie value from
> >> the request sent by the browser.
> >
> > I did a test to check this.
> > After running a report I deleted the cookie from Firefox, tried to
> > export and got the error message -> correct behaviour.
> > But if I run the report, export to excel (and get the spreadsheet),
> > rerun the report with different parameters, delete the cookie and
> > click on export, I get the same spreadsheet as before. Looks like the
> > request to the export asp file with the associated cookie gets cached
> > for some reason.. and I don't believe is on Apache, because if I kill
> > it and rerun it between the two export requests, the behaviour is the
> > same.
> >
> >> Maybe you should log the value of the cookie in various different
> >> spots so you can follow the cookie's progress and see where it gets
> >> mixed up. Places where you could log or view the cookie are:
> >> - in your app where it creates and uses the cookie values
> >> - in the access log for both Tomcat and Apache (the docs describe how
> >> to log cookie values)
> >> - in the browser, using a tool like LiveHTTPHeaders or ieHTTPHeaders
> >
> > Yes, I'll try to check the content of the cookies in the different
> > places.. i'll check out also the tools for the headers, that will be
> > useful as well.
> >
> > Thanks for your time
> > Riccardo
> >
> >
> >
> >
> >
> >> --
> >> Len
> >>
> >> On 7/26/07, Riccardo <riccardo.andretta@(protected):
> >> > Hi,
> >> > I'm experiencing a problem with cookies cached - probably - in Tomcat
> >> > for a couple of minutes.
> >> > I'm running a webapp into Tomcat, which also connects to an apache
> >> > proxy to embed an external page into the tomcat webapp. I need the
> >> > apache proxy to get rid of the Javascript safety problems that occur
> >> > when trying to interact with a page sourced from another domain name.
> >> > The problem: I run in the externally source page a report, setting a
> >> > few parameters. These parameters with my selected values are stored in
> >> > a cookie called "Reports". After running the report I can click on a
> >> > link to export it to excel. The asp script on the remote server will
> >> > retrieve the params values from the cookie and generate the
> >> > appropriate excel sheet. Now if after running a report I run another
> >> > one, the cookie on my browser gets correctly updated, but if after
> >> > that I try to export to excel this new report what I get from the
> >> > remote server is the same excel sheet as before. I checked the Reports
> >> > cookie on my browser and I see it's correctly updated after each
> >> > report run, but i noticed that what is sent to the remote server is
> >> > not the cookie stored in my browser, but a previous cookie, cached - i
> >> > suppose - in Tomcat, because the generated excel sheet is the same as
> >> > before, as the first report i've run. If i wait two minutes though and
> >> > click again the excel export function, the correct sheet is built. So
> >> > looks like Tomcat caches the Reports cookie for two minutes and this
> >> > overrides the browser cookie.
> >> > Another confirmation of this is that if I delete the Reports cookie
> >> > from my browser after running a report, and click on export to excel,
> >> > I still get the excel sheet, whereas after a couple of minutes the
> >> > sheet can't be built anymore and some microsoft runtime error is
> >> > generated.
> >> >
> >> > I was first thinking that it could be the apache proxy to cause this,
> >> > so i tried to shut it down and up again after running a report and
> >> > before trying to export it to see if it lost the cookie value in its
> >> > cache, but this was not the case, so I ended up assuming the caching
> >> > is happening inside Tomcat.
> >> >
> >> > I'm using Tomcat 5.0.28 and apache http server 2.2.4.
> >> >
> >> > Any suggestion will be much appreciated as i've alredy wasted a lot of
> >> > time on this issue!!
> >> >
> >> > ---------------------------------------------------------------------
> >> > To start a new topic, e-mail: users@(protected)
> >> > To unsubscribe, e-mail: users-unsubscribe@(protected)
> >> > For additional commands, e-mail: users-help@(protected)
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@(protected)
> >> To unsubscribe, e-mail: users-unsubscribe@(protected)
> >> For additional commands, e-mail: users-help@(protected)
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.