DONT USE SCRIPTLETS IN JSP!.
You must understand jsp
(views) code is executed in client side, java one is at server (host) one.
In order to get variables from the host side, you have plenty vays, but for small things best option is to make an ajax call:
$.get( "javaFunction",
{ variable: "VALUE" }
).done(function( data ) {
alert("Java function returned " + msg);
});
In java you need to map the url
:
@RequestMapping(value = "/javaFunction", method = RequestMethod.POST)
public
@ResponseBody
String javaMethod(@RequestParam("variable") String variable) {
if (variable.equals("VALUE") {
return "Correct call!";
} else {
return "Mistake!";
}
}