I want to call a java function named setrowNumber(1), that sets the row number to a static int variable. And I want this function to be called when the link is clicked but that does'nt seem to happen.
The problem is in that part only because when i try to set the value manually it works fine.
<a href="single.jsp" onclick= "<%conc.setrowNumber(1);%>" > <i class="glyphicon glyphicon-menu-right icon" ></i></a>
I am making java web application on struts framework, using net beans and wamp server.
If I use javascript function and use it with onclick event then how can I pass value to java function.e.g
<a href="single.jsp" onclick= "myFunc(1)" > <i class="glyphicon glyphicon-menu-right icon" ></i></a>
<script type="text/javascript">
function myFunc (int a) {
<% conc.setrowNumber(a); %> //how to write java function and pass value here because a is not known var here.
}
</script>
onclickevent handler is executed in the browser. Normally this would be JavaScript. JSP scriptlets are executed on the server before the page is sent to the browser. You could have a scriptlet that generates some JavaScript and embeds it in the page as anonclickhandler, or you could have anonclickhandler that sends an XmlHttpRequest to a servlet or JSP to execute some function on the server. But your current approach doesn't make sense.