//the same id must be used to validate the response, the session id is a good candidate!
//Look for the captcha parameter from the session if it's null create a new audio challenge
String captchaId = request.getSession().getId();
//challenge = CaptchaServiceSingleton.getInstance().getSoundChallengeForID(captchaId);
SoundCaptchaService soundCaptchaService = new DefaultManageableSoundCaptchaService();
challenge = soundCaptchaService.getSoundChallengeForID(captchaId);
request.getSession().setAttribute(WebKeys.SESSION_JCAPTCHA_SOUND_SERVICE, soundCaptchaService);
}
AudioSystem.write(challenge, AudioFileFormat.Type.WAVE, soundOutputStream);
soundOutputStream.flush();