How to persist data between sessions when using a Filter?
posted 12 years ago
Hello all in the ranch,
I've come against a tough barrier! I'm using a Filter that handles all requests to JSPs. The way the filter works is that any call to a JSP first instantiates a specific servlet from a specific class, which does some processing and binds some objects to the session before the command is passed in the filter chain to the originally requested resource (the originally requested JSP). The JSP then uses the data held in the session by its request.getAttribute() method.
The problem is that I am using a form and submit button on the first JSP (which posts the form data to a second JSP) and upon hitting that button, I believe a new session is created, meaning that the objects created and bound to the session by the first servlet are no longer available. How do I make these objects that were bound to the session by the first servlet available to the second servlet?
I've tried request dispatching but this doesn't work because the requested JSP itself needs to use objects created by its corresponding servlet. I would prefer to keep the submit button, but if unavoidable I may have to use the standard (non-submit "button") button (with onClick to move to the next JSP). Could anyone offer some advice, please?