Originally posted by colin shuker: OK, but I don't know how to do that? Do you know how to code it???
[ August 29, 2005: Message edited by: colin shuker ]
Colin, Looking through your recent posts, I can see that several people (including myself) have given you detailed explanations for binding variables to scope - with code examples. I've also posted this link: http://csajsp-chapters.corewebprogramming.com/CSAJSP-Chapter13.pdf which is a chapter that covers the topic completely. Javaranch is not a code mill. The folks here take great pride in helping new developers learn the craft but will quickly grow to resent someone who appears to want the code written for him/her.
Why don't you try this out yourself (using some of the code examples already given to you) and/or read that chapter again to see if you can get a grasp on the topic? If you get stuck, post your code and someone will be happy to point out where you're going wrong.
Hi, I finally managed to do it myself as you suggested. My solution is different to anything I've seen before since I'm using a Boolean object for the attribute of each session. I'm not totally sure if its right because I don't understand this subject, but it seems to be working fine.
Here is the code I inserted into my front page JSP (which is also linked to from other pages in the site)
This looks good. The object in session can be anything ("null" or "not null" is all you care about).
Why are you putting the "count" object into session? Is it to make it available to other pages?
You may, at some point, want to consider saving this value to a file or database so that it doesn't get reset everytime you restart the server or re-load the app.
Joined: Apr 11, 2005
The total number of vists (count) needs to be dislpayed in a separate file. I thought about using beans to do this, but I got really confused. I think setting as an attribute of application works well, becuz its clear whats going on, you dont need to think about sessions.
I'm using this Boolean object, becuz before with the way I was doing it before, there was a page in the site that linked back to this front page, causing the count to go up by 1 again, which isnt what I want.