Hi I have an HTMl form that auto-generates a captcha image and then an audio clip is generated automatically according to the captcha genenrated. the form looks as follows.
<div class="formRow">
<div class="field">
<img style="margin-left:91px; margin-top:-6px;" class="image" src="http://www.abc.com/captchaServlet">
</div>
</div>
<div class="formRow">
<div class="field">
<audio style="margin-left:91px;" controls="controls">
<source id="audiowav" src="http://www.abc.com/getSound" type="audio/wav">
Your browser does not support this audio format.
</audio>
</div>
</div>
When the captcha is generated then I store the captcha code in the session as an attribute and then when i have to generate audio file then i get the attribute from session and generate it. But what happens sometimes is that when i refresh the page the audio tag servlet gets called first i.e. http://www.abc.com/getSound gets called before http://www.abc.com/captchaServlet does so the image and audio dont match. So i want to make sure that first http://www.abc.com/captchaServlet gets called from the form and then
http://www.abc.com/getSound.
You have no guarantee that will happen because that is the browser which is deciding in which order to load the resources, which is browser dependent and you can’t really force it to follow a specific order as such.
You should have your captcha work in a different way. Maybe have the actual code generated by the page and put in the session, and then the
getSoundandcaptchaServletgenerating the respective sound or image from the code in the session?