应用session对象实现登陆
2017-05-04 16:23
141 查看
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form name="form1" method="post" action=""> 用户名:<input name="name" type="text" id="name" style="width: 120px"><br> 密码:<input name="pwd" type="password" id="pwd" style="width: 120px"> <br> <input type="submit" name="Submit" value="提交"> </body> <% String[][] userList={{"bjh",123},{"zsf",234},{"thd",345}};//创建二维数组 boolean flag=false; //登陆状态 request.setCharacterEncoding("UTF-8"); //设置编码 String username=request.getParameter("username"); //获取用户名 String password=request.getParameter("pwd") //获取密码 for(int i=0;i<userList.length;i++){ if(userList[i][0].equals(username)){ //遍历二维数组 if(userList[i][1].equals(pwd)){ flag=true; break; // 跳出循环 } } } if(flag){ //如果值为true ,表示登陆成功 session.setAttribute("username",username); //保存用户到session中 response.sendRedirect("main.jsp"); //跳转到main.jsp }else{ response.sendRedirect("index.jsp") //跳转到登陆也买页面 } %>
相关文章推荐
- 应用RMS实现用户自动登陆功能
- 6Filter应用5实现用户自动登陆的过滤器
- SpringMVC拦截器应用(实现登陆认证)
- 应用RMS实现用户自动登陆功能
- Spring Boot 搭建应用实现登陆实例,页面使用bootstrap
- 钉钉实现企业级微应用免登陆详解
- 数字证书在WEB应用中实现登陆
- 用shareSDK实现ios应用第三方登陆和分享到第三方功能(一)
- Viewpager:实现android初次登陆浏览应用界面效果
- springmvc拦截器应用(实现登陆认证)
- Java数据结构与算法之数组应用——用户登陆与注册数组实现
- 实现一个简单的struts2应用(实现登陆)
- 腾讯微博应用授权隐式登陆实现
- Servlet和JDBC的登陆实现应用
- ionic2 判断是否是第一次登陆应用是否实现启动页的显示
- Android 应用中验证码登陆都有哪些实现方案
- 通过使用第三方SDK来实现应用的分享,第三方登陆,数据信息统计等功能(ShareSDK)。
- Android SharedPreferences应用 实现本地注册登陆 功能简单易懂(实例)
- PhoneGap 跨平台应用:HealthWorking (2) 通过REST Service与服务器交互实现登陆
- 应用RMS实现用户自动登陆功能