How to validate javascript and html code? : <p>In our application end users are provided with a textbox where they can paste their html or javascript code to create advertisement  much like Google advertisement , so I need to validate these html and js source code against malicious code and also proper syntax .
So are there any API's available in java to do the same ?</p>

<p>Thanks in advance
Ali.</p>
