login.jsp

<body>
  <form action="checkLogin.jsp">
  <table>
  <tr><td>用户名:</td><td><input type="text" name="name"></td></tr>
  <tr><td>密&nbsp;&nbsp;码</td><td><input type="password" name="password"></td></tr>
  <tr><td colspan="2"><input type="submit" value="提交"></td></tr>
  </table>
  </form>
  </body>

checkLogin.jsp

<body>
  <%
  String name=(String)request.getParameter("name");
  String password=(String)request.getParameter("password");
 
  if(name.equals("admin")&&password.equals("admin")){
  session.setAttribute("name",name);
  session.setAttribute("password",password);
  response.sendRedirect("success.jsp");
  }else{
  response.sendRedirect("error.jsp");
  }
   %>
  </body>

success.jsp

<%
    String name=(String)session.getAttribute("name");
    String password=(String)session.getAttribute("password");
    out.println("用户名:");
    out.println(name);
    out.println("<br>");
    out.println("密码:");
    out.println(password);
   %>
   <a href="buygoods.jsp">购买商品</a>
  </body>

buygoods.jsp

<body>
  <%
  String name=(String)session.getAttribute("name");
  String password=(String)session.getAttribute("password");
 %>
  你好<%=name %>sessionId<%=session.getId() %>
  谢谢你购买本商品
 <a href="logout.jsp">注销</a>
  </body>

logout.jsp

<%
  session.invalidate();
  response.sendRedirect("login.jsp");
   %>

count.jsp

<body>
    <%
    if(application.getAttribute("count")==null){
    application.setAttribute("count",0);
    }
    Integer count=(Integer)application.getAttribute("count");
    application.setAttribute("count",(Integer)(count.intValue()+1));
     %>
     你好,你是第<%=count %>个访问本站的人
  </body>

session实现购物系统的简例和application实现统计页面访问次数的简例的更多相关文章

  1. Java Web之网上购物系统(注册、登录、浏览商品、添加购物车)

    眼看就要期末了,我的专业课也迎来了第二次的期末作业---------<网上购物系统>.虽然老师的意图是在锻炼我们后台的能力,但是想着还是不利用网上的模板,准备自己写,以来别人写的静态页看不 ...

  2. 基于WEB的网上购物系统-ssh源码

    基于WEB的网上购物系统主要功能包括:前台用户登录退出.注册.在线购物.修改个人信息.后台商品管理等等.本系统结构如下:(1)商品浏览模块:        实现浏览最新商品        实现按商品名 ...

  3. 案例:我行我素购物系统 v1.1

    系统逻辑结构: import java.util.Scanner; public class ShoppingSystem { public static void main(String[] arg ...

  4. java基本打印练习《我行我素购物系统》

    public class ShoppingSystem{ public static void main(String[] args){ //System.out.println("**** ...

  5. DAY4:简单购物系统

    根据前几天对于循环和列表的学习,做了一个简单的购物系统: 密码模块就是前篇文章已经做过就,直接调用过来就行,简单说一下该购物系统功能 1,展示货物,需要手动添加,haha 2,判断余额是否充足并充值 ...

  6. python 操作mysql数据库之模拟购物系统登录及购物

    python 操作mysql数据库之模拟购物系统登录及购物,功能包含普通用户.管理员登录,查看商品.购买商品.添加商品,用户充值等. mysql 数据库shop 表结构创建如下: create TAB ...

  7. [ python ] 购物系统

    作业需求 1. 购物系统,能够注册登录,用户第一次登录后,让用户输入金额,然后打印商品列表2. 允许用户根据商品编号购买商品3. 用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒4. 购买完一 ...

  8. Python3 函数实践之简易购物系统

    函数实践之简易购物系统 项目主要需求: 用户可以自行选择功能 该购物系统具有注册/登录/购物/购物车/退出登录功能 用户在登录后才能使用购物/购物车/退出登录功能 ''' 注册 登录 购物 购物车 退 ...

  9. 基于Spring MVC + Spring + MyBatis的【网上购物系统】

    资源下载:https://download.csdn.net/download/weixin_44893902/45601185 练习点设计:修改.删除 一.语言和环境 实现语言:JAVA语言. 环境 ...

随机推荐

  1. C#中部分方法返回值类型为什么只能是void?

    这个问题答案选至<C#入门经典> 如果方法具有返回类型,那就可以作为表达式的一部分: x=Manipulate(y,z); 如果没有给部分方法提供实现代码,编译器就会在使用该方法的所有地方 ...

  2. 与众不同 windows phone (52) - 8.1 新增控件: AutoSuggestBox, ListView, GridView, SemanticZoom

    [源码下载] 与众不同 windows phone (52) - 8.1 新增控件: AutoSuggestBox, ListView, GridView, SemanticZoom 作者:webab ...

  3. Hibernate关联映射及高级查询

    一.Hibernate中的关联关系 1.1.单向一对多关联关系 按照以下步骤配置hibernate中持久化类的一对多对象关联: (1).持久化类添加关联类的相关属性及getter/setter方法. ...

  4. No.012:Integer to Roman

    题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from ...

  5. 亲们! 首次见面! 带来不适!多多见谅!--------->>Bank系统

    亲们!您们好! 讲一下Bank系统的做法: 01.首先创建一个Card类 using System; using System.Collections.Generic; using System.Li ...

  6. rabbitmq学习笔记1 安装和配置

    环境 OS: CentOS Linux release 7.1.1503 (Core) kernel:3.10.0-229.el7.x86_64   安装 参考:http://www.rabbitmq ...

  7. DOM笔记整理及应用实例

    一.前言 当网页被加载时,浏览器会创建页面的文档对象模型(Document Object Model).HTML DOM 模型被构造为对象的树 通过可编程的对象模型,JavaScript 获得了足够的 ...

  8. NullPointerException at android.widget.AbsListView.obtainView at android.widget.ListView.makeAndAddView

    使用ExpandableListView的时候,报如下错.网上搜索发现原来是在CommonNumberQueryAdapter的getGroupView()方法里返回的是null,注意细节哦!!! 1 ...

  9. wpf 窗口程序下将datagrid导出为excel

    今天用了几个小时也没有找到将datagrid导出为excel的方法,搜索msdn发现,老外也木有解决这个问题,因此把代码贴出来,和大家分享一下,提高工作效率.简要说一哈,本程序使用反射,因此代码量看起 ...

  10. 为什么要用rem

    为什么要用rem 参考文章web app变革之rem 公司使用的375*667(也就是iPhone6)作为缩放比例标准,设计师是按照750px的标准出图 为了保证在不同的屏幕下显示效果基本等同,为此规 ...