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>

  • 相关阅读:
    js在字符串中提取数字
    checkbox简单例子
    递归算法及经典递归例子代码实现
    e
    MyEclipse10中启动出现OutOfMemoryError: PermGen space如何解决
    VB php JAVA关于数据库连接数过多的解决方法
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    KindEditor得不到textarea值的解决方法
    php创建读取 word.doc文档
    php 在web端读出pdf 与各种文件下载
  • 原文地址:https://www.cnblogs.com/cancangood/p/4451976.html
Copyright © 2011-2022 走看看