To understand why it is working that way the best thing is to look at the
generated java file (in the work directory).
Youy will see that when you use <%!  the variables are defined at the java
class level
When you use <% the variables are defined within the jspservice method (that
is they are local variables).

Thierry.

-----Original Message-----
From: Hugo Lara [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 7:53 PM
To: 'Craig O'Brien'
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: I don't want cached pages


Craig,

I want to thank you for your help. I tried the carts.html example with the
following results:
- In my machine I added some articles to the cart. Then I closed my browser
and opened it again. When I ran the example and added 1 more item, I noticed
that all of the items I've added before where still in the cart, which
didn't look nice to me.
- Then I went to another computer and tried the same example. I added 1 item
to the cart and I was expecting to a list with the items I've added in my
computer, but I saw just 1 item. Which was perfectly fine.

I opened the carts.jsp file and noticed that the bean they where using had
"session" as the parameter in "scope". Anyway, I didn't used beans in my
.jsp file (the one I had troubles with), but it made think it wasn't the
page that remained cached but the variables I was using, so I reviewed my
.jsp file and I found the problem:

I was initializing my variables with something like this,

<%!
  String strOne = "", strTwo = "", strThree = "";
  Double dblNumber = 0.0;
  Locale currentLocale;
%>

Then I used some java code to assign these variables some values and I
expected that the variables where initialized each time I called the .jsp
file but it wasn't like that.

Removing the "!" solved the problem. My variables are now initialized like
this,

<%
  String strOne = "", strTwo = "", strThree = "";
  Double dblNumber = 0.0;
  Locale currentLocale;
%>

It's like if I use "<%!" to initialize the variables, they are initialized
just the first time the page is called, and the subsequent values assigned
to them remain on the next requests to the page.
Using only "<%" seems to initialize the variables on each request.

Do these ideas make any sense or I'm just to tired?

I'm not really sure why this is working like this, but it's working!



-----Original Message-----
From: Craig O'Brien [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 5:39 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: I don't want cached pages


I cannot duplicate your problem.  Are you having the same problem with the
JSP example carts  http://localhost:8080/jsp/sessions/carts.html ?  Are you
using Apache?  I am using IIS5 but am having no problems.  I have several
applications like you mention and I can open up multiple instances of the
same browser on the same machine and no information is passed between them.

You may try printing the session id to the screen to see if you are having a
problem there.  You could try specifying a non-persistent connection in the
JSP page, and next a non-persistent connection in the server.

Good luck,
Craig







-----Original Message-----
From: Hugo Lara [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 3:10 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: I don't want cached pages


I'm just one more guy with the same trouble: Tomcat is caching my pages.

I use a page that receives certain parameters and gives a result. And
everytime I made a request in the browser for that particular .jsp page, I
get the last version of that page served. It means that anyone entering my
site would see the last served paged with the results from the last visitor,
which is something terrible.

I've received some kind emails from the community suggesting me to include
the "Expires", "Pragma" and "Cache-control" (with the appropiate values) in
the header to avoid caching. This is not working, and that's because (and
I'm convinced of this) it's not a browser/proxy problem.
It is Tomcat that keeps the last version cached, and I'm sure of it because
it's enough to restart Tomcat to solve the problem.
Anyway, it will be crazy to restart Tomcat every time a visitor wants to
enter my site.

I've been reading the mailing and I've noticed there's a lot of people with
the same problem and no real solution.

I know that Amos Shapira and David S. Adress have been through the same.

If anyone has the solution to this problem please tell me, I need it very
badly.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to