How to call a specific JSP script?
hi.. i am just starting to learn JSP
how can i call a specific jsp script <% %> on mouse button click?
hi.. i am just starting to learn JSP
how can i call a specific jsp script <% %> on mouse button click?
You mean like this:
<% String getTheVal = (String)session.getAttribute("sessionVal"); %>
function callMe() {
var val = '<%= getTheVal %>';
alert(val);
}
<input type="button" value="button" onclick="javascript:callMe()">
Warning:
Any java scriptlet inside a javascript function is called and executed when the JSP page is created (the JSP file is compiled and instansiated into a java servlet). It is not executed when you click an onclick button that calls the javascript function. Clicking the onclick button does not rebuild the JSP file. Therefore you can only use java scriptlet in a javascript function to initially set some value when the JSP page is first created.
Example:
document.textField1.value=<%=myBean.getFirstName()%>