JSP第三次作业

1.任务一、教材P39实验3

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'index.jsp' starting page</title>

  </head>
  
  <body bgcolor=cyan>
  <br>英文课文(English Audio):<br/>
  <p style ="font-family:宋体 ; font-size:18;color:black">
  <jsp:include page="english/english.txt"/>
  <br>课文音频(English Audio):<br/>
  <jsp:include page="audio.jsp"/>

  </body>
</html>

 

 

 audio.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><embed src="english/english.mp3" autostart ="false">
  record
  </embed>
  <body>
    This is my JSP page. <br>
  </body>
</html>

 

2.任务二、教材P45  8题

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'main.jsp' Shape page</title>
    

  </head>
  
  <body>
    This is my JSP page. <br>
  <% double r=6.6; %>
    <p>计算半径为<%=r %>的圆</p>
    <jsp:include page="/shape/circle.jsp">
    <jsp:param value="<%=r %>" name="valueR"/>
    </jsp:include>
    <br>
  <% int a=6,b=8,heigh=9; %>
    <p>计算上底<%=a %>、下底<%=b %>、高<%=heigh %>的梯形</p>
    This is a Ladder.<br>
    <jsp:include page="/shape/ladder.jsp">
    <jsp:param value="<%=a %>" name="ValueA"/>
    <jsp:param value="<%=b %>" name="ValueB"/>
    <jsp:param value="<%=a %>" name="ValueC"/>
    </jsp:include>
  </body>
</html>

 

 

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <%! public String getRadius(double r){
  double a=0;
  if(r>0){
  a=r*r*3.1415;
  return ""+a; 
  }else{
  return "radius error";
  } 
  }
  %>
  <%
  String valueR = request.getParameter("valueR");
  double r= Double.parseDouble(valueR);
   %>
  
    <title>My JSP 'circle.jsp' starting page</title>
    

  </head>
  
  <body>
  <p>count the Vaules of circle <%=getRadius(r) %></p>
  </body>
</html>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>My JSP 'ladder.jsp' starting page</title>
<%!public String getLadder(int a,int b,int c){
double product;
if(a>0&&b>0&&c>0){
product=(a+b)*c/2.0;
return ""+product;
}else{
return "parameter value error";
}
}
%>
<%
String ValueA=request.getParameter("ValueA");
String ValueB=request.getParameter("ValueB");
String ValueC=request.getParameter("ValueC");
int a=(int)Double.parseDouble(ValueA);
int b=(int)Double.parseDouble(ValueB);
int c=(int)Double.parseDouble(ValueC);
%>

</head>

<body>
<p>count the Vaules of ladder <%=getLadder(a,b,c) %></p>
</body>
</html>

3.任务三、详见Word图片

4.任务四、详见Word图片

posted @ 2022-04-03 10:35  计算机1903孙铭泽  阅读(17)  评论(0编辑  收藏  举报