JSP第三次作业

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

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  </head>
  
  <body bgcolor=blue>
    <embed src="english/english.mp3" autostart = false>
    课文音频
    </embed>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  </head>
   <body bgcolor = cyan>
     <br>英文课文(English Text):</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"/>
     </p>
  </body>
</html>

 

 2.任务二、教材P45  8题

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
    <%!double getarea(double r){
           double area=3.14*r*r;
           return area;
   } %>
   <%
   String r=request.getParameter("r");
   double r1=Double.parseDouble(r);
   double area=getarea(r1);
   out.print("圆形的半径是"+r+",圆形的面积:"+area);
    %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  </head>
  <body>
     <%!double getarea(double t,double b,double h){
           double area=(t+b)*h/2;
           return area;
   } %>
   <%
   String string=request.getParameter("t");
   double top=Double.parseDouble(string);
   string=request.getParameter("b");
   double bottom=Double.parseDouble(string);
   string=request.getParameter("h");
   double hight=Double.parseDouble(string);
   double area=getarea(top, bottom, hight);
   
   out.print("梯形的上底是"+top+"下底是"+bottom+"高是"+hight+"面积是"+area);
    %>
   
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 <%!double r=(int)(Math.random()*10)+1; %>
<jsp:include page="circle.jsp">
<jsp:param name="r" value="5"/>
</jsp:include>
<br>
<jsp:include page="ladder.jsp">
<jsp:param name="t" value="4"/>
<jsp:param name="b" value="8"/>
<jsp:param name="h" value="8"/>
</jsp:include>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'index1.jsp' starting page</title>
  </head>
  <body>
  </body>
</html>

 

 3.任务三、详见Word图片

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

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

  </head>
  
  <body>
     <table border="2" height="300" width="500" align="center" bgcolor="cyan">
      <tr align="center"><td colspan="2"><%@include file="header.jsp" %></td></tr>
      <tr align="center"><td><%@include file="left.jsp" %></td><td align="center">
  <%@include file="right.jsp" %></td></tr>
  
  <tr align="center"><td colspan="2"><%@include file="footer.jsp" %></td></tr>
  </table>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="我是header.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="我是left.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="我是right.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="我是footer.jsp文件" %>

 

 4.任务四、详见Word图片

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  
  <body>
     <% 
   String s=request.getParameter("number");
   int a=Integer.parseInt(s);
   out.println("随机数是"+a);
    %>
    <h1>Hello,我是一个偶数!</h1>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
      <% 
   String s=request.getParameter("number");
   int a=Integer.parseInt(s);
   out.println("随机数是"+a);
    %>
    <h1>Hello,我是一个奇数!</h1>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>index</title>
  </head>
  
  <body>
    <h1>产生一个0到10的随机整数</h1>
    <%
    int i= (int)Math.round(Math.random()*10);
    if(i%2==0){
     %>
     <jsp:forward page="even.jsp">
     <jsp:param value="<%=i %>" name="number"/>
     </jsp:forward>
     <%
     }else{
      %>
      <jsp:forward page="oddNumber.jsp">
      <jsp:param value="<%=i %>" name="number"/>
      </jsp:forward>
      <%
      }
       %>
  </body>
</html>

 

posted @ 2022-04-01 11:14  热血青年小刘  阅读(21)  评论(0编辑  收藏  举报