Execute java code though javascript w/o ajax
<p>I am trying to implement java code on a web based application to reduce redundancy and increase OOP principles</p>

<p>I have a phone validation regular expression on server side java code.  I have a requirement to perform the same validation on the browser as people are adding information, without communicating with the server.  I understand I can place the same code into the javascript but then I have two locations to maintain the same code.  I am looking for a simple way to send the regular expression function with the http response.</p>

<pre><code>//java code
Class myVerf
{
    bool verPhone(input) {return //comepare verPhone to regEx}
}

//html
input type = "text" id = "1" onkeypress = "verPhoneFunc()"

//javascript
function verPhoneFunc()
{
    //get value from id 1
    //execute verPhone java code
}
</code></pre>

<p>Are there any downfalls to doing this?  EX: what happens if there is no JVM on the machine the browser is running in?  How does the java code execute on the browser?</p>

<p>I want to emphasise again...  I cannot use AJAX because I can not communicate with the server.</p>
