java – Using jQuery/JavaScript Code in JSP – Education Career Blog

I have jQuery code in a JSP:

${'#userid').val('admin')

The app server is interpreting the jQuery code as JSP:

The function val must be used with a prefix when a default namespace is not specified

How do I “escape” the JavaScript?

,

There is absolutely no problem in using javascript in jsp pages.

Your example does not work because it is not valid jQuery – instead it starts like an EL expression. Your first bracket should not be curly:

$('#userid').val('admin')

Leave a Comment