I want to use scriptlet to write the function called when clicking the Execute Test button This code didn\'t work :
Here\'s my jsp code :
<%@ page lan
You can do as follows.
if(request.getParameter("btnSubmit")!=null) //btnSubmit is the name of your button, not id of that button.
{
java.util.Date d = new java.util.Date();
System.out.println(d.toString());
}
<input type="submit" id="btnSubmit" name="btnSubmit" value="Execute Test"/>
onclick="executeTest()"
with your button tries to invoke a Javascript function. Change your button tag as mentioned in the above code and encolse this code within a sciptlet. It will do the job when you click this button.
Additionally, you may want to replace
System.out.println(d.toString());
with
out.println(d.toString());
in your code.
Also, in your form tag,
<form enctype="multipart/form-data" method="get">
the attribute enctype="multipart/form-data"
is required when you're uploading files. You should remove it, if such is not a case and
method="post"
The form attribute enctype="multipart/form-data"
can not work, if you use method="get"
I think you're confusing Java functions and Javascript functions i.e., server-side vs client-side.
We cannot call the functions which are written in jsp page using java. We can use the javascript for creating events and submit the values to the another jsp page for further processing.