Boolean isResponseCorrect =Boolean.FALSE;
//remenber that we need an id to validate!
String captchaId = httpServletRequest.getSession().getId();
//retrieve the response
String response = httpServletRequest.getParameter("j_captcha_response");
// Call the Service method
try {
isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId,
response);
} catch (CaptchaServiceException e) {
//should not happen, may be thrown if the id is not valid
}
//do something according to the result!
|