Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Initializing captcha from session  RSS feed

 
c york
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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:
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the question is about when things are being put into the session, then we need to know more about that toggling and clicking which you just casually mentioned in the introduction to your post. You seem to be treating the issue as if everything is happening at one time -- at least you're asking about a JSP, when in reality things are happening on the client which cause requests to be sent to the server.
 
c york
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. 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.

Hopefully, I gave you enough information this time; if not, please let me know.

Thanks
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!