I have a text box in index.jsp and after writing something i am calling a jsp by jquery. But my requirement is if a particular value will be matched in server side then how can i auto refresh that text box? It means suppose i entered apple then by onkeyup event i am sending the name(apple) to check.jsp and in this jsp page, I have kept apple in a string. So now an alert will come in index.jsp that apple already exists and simulatenously that text box will be auto refreshed. How can i do it? I am a beginner to this field.
index.jsp
<script type="text/javascript">
$(document).ready(function() {
$("#textbox").keyup(function () {
$.getJSON('check.jsp', {
textboxname: this.value
});
});
});
</script>
inside body
<input type="text" id="textbox" name="textboxname"/>
check.jsp
String textboxname=request.getParameter("textboxname");
on keyup send the value to the server and if it matches return true or false, then in the success handler check what is returned if its true refresh and not do something
on the server not the exact servlet code but you’ll get the idea