zoukankan      html  css  js  c++  java
  • JSP第三次作业实验

    实验一 消费总和

    <%@ page language="java" contentType="text/html" import="java.util.*"  pageEncoding="utf-8"%>
    <%@ page import="java.util.regex.Pattern"%>
    <%@ page import ="java.util.regex.Matcher"%>
    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <%!
    public double getPriceSum(String input){
         Pattern pattern;
         Matcher matcher;
         String regex="-?[0-9][0-9]*[.]?[0-9]*";
         pattern = Pattern.compile(regex);
         matcher = pattern.matcher(input);
         double sum=0;
         while(matcher.find()){
            String str = matcher.group();
            sum+=Double.parseDouble(str);
            }
        return sum;
        }
     %>
    <body bgcolor=cyan>
        <p style ="font-family:黑体;font-size:20">
        <br>张三的菜单:</br>
        <%String str= "麻婆豆腐:20.6元,红烧肉:68.9元";
         %>
        <br><%=str%></br>
        <br><b><i>消费总和:<%=getPriceSum(str) %></i></b></br>
        <br>李四的菜单:</br>
        <%str= "剁椒鱼头:62.9元,烤鸭:199元,红焖大虾:289.9元";
         %>
        <br><%=str %></br>
        <br><b><i>消费总和:<%=getPriceSum(str) %></i></b></br>
        </p>
    </body>
    </html>

     实验二  日期时间

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ page import = "java.time.LocalDate" %>
    <%@ page import = "java.time.LocalTime" %>
    <%
        LocalDate date = LocalDate.now();
        LocalTime time = LocalTime.now();
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      </head>
      
      <body>
         <h2>
            用户在<%=date.getYear()%>/<%=date.getMonthValue()%>/
         <%=date.getDayMonth()%><br>
         <%=time.getHour()%>:<%=time.getMinute()%>:<%=time.getSecond()%>访问了网页.
         </h2>
      </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>
        <h1>显示访问网页的日期、时间<br>(服务器端的日期、日期)</h1>
        <%@ include file = "time.jsp"%>
      </body>
    </html>

    实验三  听英语

    <%@ 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>
      <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>
    <%@ 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>
      <body bgcolor=pink>
      <embed src="english/english.mp3"autostart=false>
        课文音频
       </embed>
      </body>
    </html>
  • 相关阅读:
    webservice 测试窗体只能用于来自本地计算机的请求
    未能加载文件或程序集system.web.extensions解决方法
    VS2010中水晶报表应用及实例
    存储过程
    Windows下wamp的配置问题(php初学者必看!!)
    IIS附加进程在Visual Studio 2010 中进行调试(高级)
    求职之(1)各公司待遇~~可能有点老了
    编译原理之(2)C++词法文件,语法文件
    STL笔记(4)关于erase,remove
    STL笔记(6)标准库:标准库中的排序算法
  • 原文地址:https://www.cnblogs.com/LILY321/p/14583449.html
Copyright © 2011-2022 走看看