1

input.jsp

<body>
<formaction="calculate.jsp"method=postname=form>
<inputtype="text"value=""name="string_1"><br>
<inputtype="radio"name="cal"value="cal_1">+<br>
<inputtype="radio"name="cal"value="cal_2">-<br>
<inputtype="radio"name="cal"value="cal_3">*<br>
<inputtype="radio"name="cal"value="cal_4">/<br>
<inputtype="text"value=""name="string_2"><br>
<inputtype="submit"value="提交">
<inputtype="reset"value="重置">
</form>
</body>

calumniate.jsp

<body>
    <%
       double num1_double = Double.parseDouble(request.getParameter("string_1")) ; 
       double num2_double = Double.parseDouble(request.getParameter("string_2")) ; 
       String cal = request.getParameter("cal");
       double result = 0; 
       if(cal.equals("cal_1")){ result = num1_double + num2_double; } 
       else if(cal.equals("cal_2")){ result = num1_double -num2_double; } 
       else  if(cal.equals("cal_3")){ result = num1_double * num2_double; } 
       else if(cal.equals("cal_4")){ result = num1_double / num2_double; }
		request.setAttribute("result_send",result); 					
       request.getRequestDispatcher("output.jsp").forward(request, response); 
       %>
</body>

output.jsp

<body>
计算结果为:<%=request.getAttribute("result_send")%>
</body>

2

timeinput.js

window.onload = function() {
  window.requestAnimationFrame(getDate)
}
function getDate() {
  window.setTimeout(function() {
​    window.requestAnimationFrame(getDate)
  }, 1000 / 2)
  var d = new Date();
  var year = d.getFullYear() //获取年
  var month = d.getMonth() + 1; //获取月,从 Date 对象返回月份 (0 ~ 11),故在此处+1
  var day = d.getDay() //获取日
  var days = d.getDate() //获取日期
  var hour = d.getHours() //获取小时
  var minute = d.getMinutes() //获取分钟
  var second = d.getSeconds() //获取秒
  if (month < 10) month = "0" + month
  if (days < 10) days = "0" + days
  if (hour < 10) hour = "0" + hour
  if (minute < 10) minute = "0" + minute
  if (second < 10) second = "0" + second
  var week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")
  var Tools = document.getElementById("Main")
  var da = year + " 年 " + month + " 月 " + days + " 日 " + week[day] + " " + hour + " : " + minute + " :" + second
  Tools.innerHTML = da
}

作业.html

<html>
<head>
  <title> 主题 </title>
  <link rel="stylesheet" type="text/css" href="homework.css">
    <script type="text/javascript" src='timeinput.js'></script>
</head>
<body>
    <p> 当前时间是:
​    <span id="Main"></span>
  </p>
</body>
</html>

homework.css

p {
  color: red;
  margin: 0 auto;
  text-align: center;
  font-size: 40px;
}

3

input.jsp
<%--
CreatedbyIntelliJIDEA.
User:Administrator
Date:2022/4/5
Time:9:28
TochangethistemplateuseFile|Settings|FileTemplates.
--%>
<%@pagecontentType="text/html;charset=UTF-8"language="java"%>
<html>
<head>
<title>Title</title>
</head>
<body>

</body>
</html>

index.jsp
<%@pagecontentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>系统时间</title>
</head>
<body>
<divid="datetime"style="color:red;text-align:center;font-size:xxx-large">
<script>
setInterval("document.getElementById('datetime').innerHTML=newDate().toLocaleString();",1000);
</script>
</div>
</body>
</html>



Main.class
packagemain;

importbeans.Circle;

publicclassMainClass{
publicstaticvoidmain(String[]args){
Circlecircle=newCircle();
circle.setRadius(2.0);
doublearea=circle.calArea();
System.out.println("半径为:"+2.0+"圆的面积是"+area);

}
}

HelloServlet.java
packagecom.example.circle;

importjava.io.*;
importjavax.servlet.http.*;
importjavax.servlet.annotation.*;

@WebServlet(name="helloServlet",value="/hello-servlet")
publicclassHelloServletextendsHttpServlet{
privateStringmessage;

publicvoidinit(){
message="HelloWorld!";
}

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException{
response.setContentType("text/html");

//Hello
PrintWriterout=response.getWriter();
out.println("<html><body>");
out.println("<h1>"+message+"</h1>");
out.println("</body></html>");
}

publicvoiddestroy(){
}
}


Circle.java

packagebeans;

publicclassCircle{
privatedoubleradius;
privatebooleanfill;
publicCircle(){

}
publicvoidsetRadius(doubleradius){
this.radius=radius;
}
publicvoidsetFill(booleanfill){
this.fill=fill;
}
publicdoublegetRadius(){

returnradius;
}
publicbooleanisFill(){
returnfill;
}
publicdoublecalArea(){
returnradius*radius*3.14;
}
}


Q.E.D.


---------我大体上尊崇理性和意志,却也不菲薄情感和想象---------