views:

22

answers:

1

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?

+5  A: 

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')
Bozho
Thanks for the fast answer!
teddy
@teddy - if the answer works for you, feel free to mark it as accepted (tick below the vote counter)
Bozho