简体   繁体   中英

I want to call a method in a scriplet by passing parameters from javascript function which is called on button click from html

I have a table in which a column has buttons . on clicking this button the function should be called and the function should inturn call a scriplet method by passing parameters from the function.This should be in the same jsp page.

I have the rough code here:

<%

public String manager(String abc, String sbc){

}
%>

<html>
<head>
<script type="text/html">
function f1(){
id = document.getElementById("E1");
id.innerHTML("print");
}



</script>
<body>
<table>
<tr><td>numbers</td></td> status</td><td>check</td></tr>
<tr><td>1</td><td ID ="E1"></td><td id="E1" type="button" value="submit" onClick="f1()"></td>

</table>


</body>

</head>

</html>

Scriptlets contain Java code which is executed to generate the HTML page, at server-side.

JavaScript code is executed in the user's browser, seconds, minutes or hours later, at client-side.

To do that, you need to trigger an AJAX call from the JavaScript function to some servlet, which will execute the Java method.

Side note: JSPs are meant to generate markup, niot to execute business logic. Code your business logic in Java classes, used by a Servlet, then dispatch to a JSP which generates the markup. The JSP code should only use the JSP EL, the JSTL, and custom JSP tags. No Java code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM