Hi,
One of the methods through which you can access
java variables in JavaScript in servlets is through hidden variables.
After retreiving the string from the database, put it as a value for a hidden field using the foll. code :
out.println("<input type=hidden name=fieldname value='"+varname+"'>");
You can access the same in JavaScript for client side validations using document.formname.fieldname.value.
I have used the same in many of my servlets.
See if this helps your cause.
Bye.
------------------