Re: Best way to store variables and user choices in JSP page
Making session variables is a costly affair for the server. And you
Making hidden variables is a costly affair for the connection.
Which cost is worse, and how are you judging that?
should avoid using that in all the conditions.
I don't think so.
If you'r server is having load balancing then it will be more costly for all the servers.
But /too/ much more costly? Not likely.
Here the user is going to traverse from one page to another so he does
not need to use session variables. Hidden varaibles can do the trick.
At a cost.
I don't think this application is passing any valuable information
like password in hidden variables which need to be secured.
If you are not using session variables then you have to send the data
by either GET or POST internally you can use MVC 2 to handle this
What is "MVC 2"?
There is nothing wrong with session variables, properly used. If something
needs to persist between requests, one must use either a session, which
collapses all session knowledge into a single "hidden variable", the session
token, or hidden variables as you describe. You seem to have an unhealthy
fear of session variables.
One should avoid session state in a web application generally, but when one
has such state, then session variables can often be a viable solution.
(Session objects should implement Serializable, which imposes additional
responsibility on the programmer, as Serializable exposes the implementation
of a class. See Joshua Bloch's excellent book /Effective Java Programming/,
which all of us should buy.)