This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi I have a JSP page which is having some fields that are getting populated from its ActionForms reset method. Everything is working fine. Also worth mentioning the scope for it is "session".
Now the problem arises when I am on this page and session timeouts. then on refreshing or while attempting to go to next page, using a button, it takes me to the login page. Thats also fine. However, when again logged it, I go to that page again, it doesnt have any data. I tried to debug it and found out that in this kind of situation the reset method in the associated page's ActionForm is not getting called and thus, the data is not getting fetched from the database. I am using Hibernate to access the database and thus to fetch data needs Session session = HibernateUtil.currentSession(); Query query = session.createQuery("from Book book");
I am not understanding where I am getting wrong. Also, I am running it on Tomcat server.
If the application is behaving differently when the session times out and you log in again than it does when you first log in, it stands to reason that something isn't getting reset properly.
The first thing I'd try would be to put some logic in the login action that would make sure nothing's hanging on from a previous session. Do a session.removeAttribute() on all your session scoped form beans. I'm not that familiar with Hibernate, but maybe there's also something you can do there to make sure you're starting with a fresh session.