I am new to JSP and I'm having a problem with captcha containing a value in the field when toggling from the first page to another and clicking submit on the second page before entering data to validate the fields and the code just falls through and returns the error "Please enter the correct code". The values returned are (captcha)96043 (code)null, captcha is not null because it is retrieved from session which is the last value captured from the page I'm assuming.
I've used request.getSession().removeAttribute( "captcha" ); before building the page to clear out the values, resetting captcha to null etc.; nothing is working. I've been researching and trying different things for a while and haven't found a solution. Hope someone can assist.
Here's the code:
Hopefully, I gave you enough information this time; if not, please let me know.
c york wrote:Ok, when the application runs, the landing page contains two links to toggle back and forth between them; one for Public and the other Business. The Public page is displayed but I wish go to the Business page, so I click the link for Business, the image that is displayed for the user to enter to continue with the submission is stored in session; this image is the captcha field (5-digit number) and is brought over from the Public page to the Business page.
And at some point in between these two parts of your description, the user is going to do something with that captcha image, right? And somewhere in there the session is supposed to be updated? That's the part which you need to understand.
The code checks if captcha != null && code != null to continue with validating the data entered on the Business page; captcha is populated from the Public page and code is null; the code to validate the fields on the second page is ignored because captcha which coming from session is not null.