我想添加一个按钮,当我单击它时应该显示日期,但按钮不起作用。
我的小服务程序:
package test.servlets;
import java.io.*;
import javax.servlet.*;
public class FunctionalTestServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws
ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String text = request.getParameter("montext");
String fileName = request.getParameter("testclass");
out.println("<b><font color='blue'>The text is :</font></b>"
+ "<b>"+ text +"</b>" + "<br>");
out.println("<b><font color='blue'>The File name is :</font></b>"
+ "<b>"+ fileName+"</b>" + "<br>");
out.println("<% public void executeTest() {" +
" java.util.Date d = new java.util.Date();out.println(d.toString()); } %>");
**out.println("<input type='submit' value='Execute Test'onclick='executeTest()'>");**
}
}
jsp页面:
<%@ 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"/>
<form action="FunctionalTestServlet" enctype="multipart/form-data" method="get">
<p>
Type some text (if you like):<br>
<input type="text" name="montext" size="30">
</p>
<p>
Please specify a Test , or a set of tests:<br>
<input type="file" name="testclass" size="40" >
</p>
<div>
<input type="submit" value="Execute Test">
</div>
</form>
</body>
</html>
任何想法请干杯