Originally posted by Raef Kandeel:
1) I used sessions to keep track of the inputted values and then I discovered that these sessions cannot keep values for more than 2 "hyperlinks". Meaning that, I input a value, press next, enter another value press next and then press two backs and the session information is gone.
If that's the case, something's wrong with your code.
Your session variables will last as long as your session unless you explicitly remove them or overwrite them.
2) Then I discovered there is something named stateless sessions and there is something named statefull sessions. And that each session has an ID and that this ID must be passed around to servers in cookies so as for the information to persist.
There's only one kind of session in the
servlet spec.
HTTP, itself is stateless; meaning that a connection to the server is created and destroyed for each and every request. This differs from stateful protocols like FTP and telnet. With these protocols, you make a connection to the server and keep that same connection until you sign out.
The server always knows who you are because you are using the same connection you were using when you signed on.
To mimmick a stateful connection servlet containers pass a session ID to the browser (usually in the form of a cookie) and then use that ID to match your session up with an object stored in memory (on the server) for all subsequent requests. The session object is essentially, a map of name value pairs. You can bind anything to it and then retrieve, by name, it in later requests by calling session.getAttribute.
Then I tried to use ready-made code. Just to test the concept and see whether it would work or not. The code is found at http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/hall/ShowSession.java. And the next thing that I know is that it is telling me it cannot resolve javax.servlet.*. I, of course can download the API and work with it, but, correct me if I am wrong, there is an easier way of doing things.
This problem has nothing to do with sessions.
It has to do with your environment not being set up properly.
[ November 05, 2007: Message edited by: Ben Souther ]