Wednesday, July 9, 2003 05:21 AM
The only way your "session" is closing after 4-5 page visits is that the user sits on one page till the session times out. If the user visits another page before the "session" times out, then the session will not be lost.
One way of preventing this, although it is not very secure, is to create a "hidden" input HTML tag that holds a value unique to the user/session. Or append such a value to every link url on every page.
When the user goes to another JSP/Servlet, the name/value pair is a request parameter and can be extracted from the request object, then placed in the next page that is referenced.
The user receives this value upon log-in and it is stored in a database associated with the user's login. You create a bean that gets this "session" value, determines if the session value is already associated with a user and validates it.
If it is valid, it allows the user to view the next page, if not, the JSP redirects the user to a log-in page.
This is not a Statefull Session Bean but it is one way to persist the session's state.
Some Web servers will persist the entire request and session object in a common database associated with a user (IBM Websphere is one) to be used for load balancing, and persisting the session state....
You can be as creative as you want to be with this.