javascript - How to call a java function from a jsp -


i require username used user in project compared other usernames registered. username should distinct. input taken in newuser.jsp in turn calls function searchforusername in semanticsearch.java. when new user registering email id checked validation , later when username typed above checking needs done. have tried 1 way not working.please point mistake doing?

my code in semanticsearch.java has constructor:

public semanticsearch() {} 

the following code follows after validation of email id.

my code in newuser.jsp is

semanticsearch myclass=new semanticsearch();  boolean rets=myclass.searchforusername(username);  if (rets==false)  {      alert("username exists");      document.getelementbyid("username").value="";      document.getelementbyid("password").value="";      document.getelementbyid("username").focus();  } 

during click event of adduser button function has called. during click function nothing seems happen. please help.

<% semanticsearch myclass=new semanticsearch();  boolean rets=myclass.searchforusername(username); // how username on button click , assign variable?  if (rets==false) { %> 

i guess can assign java variable javascript variable

var username = '<%= username%>'; 

but vice versa work?

<%string username = %>document.getelementbyid("username").value<%:%> 

i prefer balusc's approach (1st one), javascript validation case can risky browsers support disabling of javascript.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -