Pass a JSP variable as parameter to javascript function

jsp

Solution

You have to use like this

<% String uname ="multiple"; %>
<form action="ExampleServlet" method="post" onclick="pagetype('<%=uname%>');"><br>
    <input type="submit" name="Log in" value="Login" />
</form>

Problem

I have a function defined inside the script tags of head.(in a JSP) I want to declare a string variable in the JSP and pass it as a parameter to this function ``` <% String uname ="multiple"; %> <form action="ExampleServlet" method="post" onclick="pagetype(${uname});"><br> <input type="submit" name="Log in" value="Login" /> </form> ``` But this doesn't work. need Help

Original source