I want to send JSP java variables that I had defined via ajax request, it it possible?
My JSP :
<%
String fileName = (String)request.getAttribute(MatafConstants.PARAM_IMG_FILE_NAMES);
%>
And then I want to send this String:
$.ajax({
url: "/some/urlServlet",
type: "get", //send it through get method
data: {
"statusID": status,
"test": '<%=fileName%>' //here is the param I send
},
success: function(response) {
//Do Something
console.log(response);
},
error: function(xhr) {
//Do Something to handle error
}
});
How can I sent this param? Or the bigger question I can I use JSP java variable in JavaScript?
<%= ...%>tag. Check the source on the client, you will see that this will be like"test": 'your parameter' //here is the param I send