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 language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<html:file properties="tonFichier" name="tonForm"/>
<%!
public void executeTest() {
java.util.Date d = new java.util.Date();
System.out.println(d.toString()); }
%>
<form enctype="multipart/form-data" method="get">
<div>
<input type="submit" value="Execute Test" onclick="executeTest()" >
</div>
</form>
</body>
</html>
Any help please
Cheers
You can do as follows.
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
with
in your code.
Also, in your form tag,
the attribute
enctype="multipart/form-data"is required when you’re uploading files. You should remove it, if such is not a case andThe form attribute
enctype="multipart/form-data"can not work, if you usemethod="get"