Search code examples
javascriptjspanchorhref

Mismatch of opening and closing quote of href while dealing with jsp session value


I am working on a jsp application. I have an User object in my session.
From jsp I can acess the following value successfully -

userType = ${USER.type};
editPermission = ${USER.hasPermission['editPermission'];  //case 1.

Here hasPermission is Map<String, Boolean>. In case 1 it returns true/false. But When I use it in a <a> it doesn't works properly. It seems the href attribute quote ('') confilicts with the 'editPermission' quotes. Please can any one help me how to solve this problem?

<a href="#tab" onclick="window.location.href='.../home.do?tbNam=all&userType=${USER.type}&editPermission=${USER.hasPermission['editPermission']}';">All</a>

Thanks in advance.


Solution

  • The variable does not evaluate in this context.

    Do like this

    <a href="#tab" onclick="window.location.href='.../home.do?tbNam=all&userType=' + ${USER.type} + '&editPermission=' + ${USER.hasPermission['editPermission']} + ';'>All</a>