ovod
ovod

Reputation: 1178

jsp pass session attribute to javascript function

I have javascript function inside JSP:

function confirmInput(projectname) {
    alert(projectname);
}

Inside JSP I have form with input:

<form onsubmit='confirmInput(<%="${sessionScope.project.name}"%>)' action="" method="get">

and session attribute project.name. Script does not work((( How in right way to pass this value to javascript function? I have not found the answer among existing similar question(((

Upvotes: 0

Views: 606

Answers (1)

glw
glw

Reputation: 1664

Try this:

<form onsubmit='confirmInput("${sessionScope.project.name}")' action="" method="get">

or

<form onsubmit='confirmInput("<%=sessionScope.getAttribute("project").name%>")' action="" method="get">

Upvotes: 0

Related Questions