zoukankan      html  css  js  c++  java
  • 编写一个简易购物车,实现向购物车内添加商品,移除指定商品及清空购物车功能。

    showp.jsp

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'shocar..jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    </head>

    <body>
    <form id="form1" name="form1" method="post" action="login.jsp">
    银行卡号:
    <input name="username" type="text" id="username"/><br>
    密&nbsp;&nbsp;码:
    <input name="pd" type="password" id="pwd"/><br>
    <input type="submit" name="Submit" value="提交"/>
    </form>
    </body>
    </html>

    index.jsp

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    </head>

    <body>
    <center><b>购物车已清空!</b></center><br>
    <center><a href="show.jsp"> 返回</a></center><!-- 超链接 -->


    </body>
    </html>

    docar.jsp:

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'docar.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    </head>

    <body>
    <%
    String action=request.getParameter("action");
    if(action==null)
    action="";
    if(action.equals("buy"))
    {
    response.sendRedirect("shopcar.jsp");
    }
    else if(action.equals("remove"))
    {
    response.sendRedirect("remove.jsp");
    }
    else if(action.equals("clear"))
    {
    %> 
         <%response.sendRedirect("index.jsp");
    }

    %>
    </body>
    </html>

    shocar.jsp

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'docar.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    </head>

    <body>
    <%
    String action=request.getParameter("action");
    if(action==null)
    action="";
    if(action.equals("buy"))
    {
    response.sendRedirect("shopcar.jsp");
    }
    else if(action.equals("remove"))
    {
    response.sendRedirect("remove.jsp");
    }
    else if(action.equals("clear"))
    {
    %> 
         <%response.sendRedirect("index.jsp");
    }

    %>
    </body>
    </html>

    login.jsp:

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'login.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->


    </head>
    <body>
    已购买。<br>
    <a href="show.jsp">继续购物</a>
    </body>
    </html>

    remove.jsp

    <%@ 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>
    <base href="<%=basePath%>">

    <title>My JSP 'remove.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    </head>

    <body>
    该功能没有实现,请不要乱点. <br>
    </body>
    </html>

  • 相关阅读:
    批量 kill mysql 中运行时间长的sql
    第三方支付过程中session失效问题
    Maven常用命令:
    根据Request获取客户端IP
    MySQL之alter语句用法总结
    转:Redis使用认证密码登录
    Git添加远程库
    输入一个三位数x,它的个位数为a,十位数为b,百位数为c,请把它的各个位数分离出来并输出。
    20161129 计算95除以55,商是多少,余数是多少?(商和余数要求分两行显示)
    20161128 已知小明同学其中考试成绩,数学97.5分,语文94.5分,英语95.5分,求小明同学的三科总成绩(结果保留一位小数)。
  • 原文地址:https://www.cnblogs.com/cancangood/p/4451976.html
Copyright © 2011-2022 走看看