为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

用户登录代码 jsp

2017-09-17 16页 doc 71KB 48阅读

用户头像

is_105949

暂无简介

举报
用户登录代码 jsp用户登录代码 jsp 登录页面 用户名:    LoginServlet: package cn.edu.qfnu.ch08.servlet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletContext; import javax.servlet.ServletException; ...
用户登录代码  jsp
用户登录代码 jsp <3(编写一个用户登录Java Web应用程序,要求使用Servelet监听器技术,当用户成功 登录后跳转到欢迎页面,在欢迎页面上显示当前在线人员的登录名称。 Login.jsp: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 登录页面
用户名:
  
LoginServlet: package cn.edu.qfnu.ch08.servlet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class LoginServlet */ public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium */ public LoginServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取用户名信息 String username=request.getParameter("username"); //将用户名信息写入Session HttpSession session=request.getSession(); session.setAttribute("username", username); //将用户名信息写入ServletContext ServletContext ctx=this.getServletContext(); List onlineUserList=(List)ctx.getAttribute("onlineUserList"); //第一个用户访问时,需要初始化onlineUserList if(onlineUserList==null){ onlineUserList=new ArrayList(); } onlineUserList.add(username); //更新onlineUserList ctx.setAttribute("onlineUserList", onlineUserList); //转到显示当前用户的Servlet response.sendRedirect("ShowOnlineServlet"); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } ShowOnlionServlet: ackage cn.edu.qfnu.ch08.servlet; import java.io.IOException; 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class ShowOnlineServlet */ public class ShowOnlineServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ShowOnlineServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取当前用户的username HttpSession session=request.getSession(); 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium String username=(String)session.getAttribute("username"); response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); out.print(""); out.print(""); out.print(""); out.print("显示当前在线的所有用户名"); out.print(""); out.print(""); out.print(""); if(username!=null){ //给出注销链接 out.print(username+"欢迎访问, 注销
"); } ServletContext ctx=this.getServletContext(); List onlineUserList=(List)ctx.getAttribute("onlineUserList"); if(onlineUserList!=null&&onlineUserList.size()>0){ out.print("当前的在线用户为:"); //显示所有当前用户 for(int i=0;i"); out.print(""); } /** 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } } LogoutServlet: package cn.edu.qfnu.ch08.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class LogoutServlet */ public class LogoutServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium public LogoutServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取session对象 HttpSession session=request.getSession(); //获取当前用户名 String username=(String)session.getAttribute("username"); //销毁session session.invalidate(); ServletContext ctx=this.getServletContext(); //在ServletContext中删除当前用户名 List onlineUserList=(List)ctx.getAttribute("onlineUserList"); onlineUserList.remove(username); ctx.setAttribute("onlineUserList", onlineUserList); //重定向到ShowOnlineServlet response.sendRedirect("ShowOnlineServlet"); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium throws ServletException, IOException { doGet(request,response); } } 经调试实验结果如图: 300 yuan, the unit will charge a fine of 100 Yuan. 7.5.3 accident penalties (1) injuries fatalities directly punished 1~2 million. Direct responsibility for the accident and have the corresponding responsibility of leadership, such as concerning administrative sanctions, should be brought to the company or the relevant Department. (2) personal injury accident occurred, the direct punishment 0.5-10,000 yuan, responsible for the direct responsibility for the accident and the responsibility of leadership, such as concerning administrative sanctions should be dealt with by the personnel Department of the company. (3) personal injury accident occurs, the direct punishment 500-1000, who is directly responsible for the accident responsibility, give notice of criticism and 50-100 economic sanctions against them. (4) to conceal the accident, reported without undue delay or false, to inform the administrative leadership of the criticism, resulting in serious consequences, the pursuit of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium
/
本文档为【用户登录代码 jsp】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索