jsp+servlet+javaBean实现MVC (关于学生登录注册修改密码)

  • G0_479289
    了解作者
  • 11.1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-14 07:12
    上传日期
自己写的一个MVC架构的小程序 是写作业来的 哈哈 为了积分就传上来了
MVC.rar
内容介绍
/* * 创建日期 May 10, 2009 * * TODO 要更改此生成的文件的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */ package com; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.sqlConnection; public class studentServlet extends HttpServlet { ArrayList al=new ArrayList() ; /** * Constructor of the object. */ public studentServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); /* response.setContentType("text/html"); PrintWriter out = response.getWriter(); out .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.print(" This is "); out.print(this.getClass()); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); */ } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); String cmd=request.getParameter("cmd"); if(cmd.equals("denglu")){ al=new ArrayList(); sqlConnection conn=new sqlConnection(); if(this.denglu(request, response)){ if(conn.checkPassword(al)){ response.sendRedirect("welcome.jsp?id="+al.get(0) ); } else{ response.sendRedirect("dengLu.jsp"); } } } if(cmd.equals("register")){ al=new ArrayList(); sqlConnection conn=new sqlConnection(); if(this.postIntoOne(request, response)){ conn.insertone(al); System.out.print(al); response.sendRedirect("dengLu.jsp"); } } if(cmd.equals("update")){ al=new ArrayList(); sqlConnection conn=new sqlConnection(); if(this.update(request, response)){ conn.updateone(al); System.out.print(al); response.sendRedirect("dengLu.jsp"); } } } public boolean postIntoOne(HttpServletRequest request, HttpServletResponse response) throws IOException { String id=null; String password=null; id=request.getParameter("ID"); password=request.getParameter("password"); if(id.toCharArray().length!=10||id==null||id.equals("")){ System.out.print(id); response.sendRedirect("register.jsp"); return false; } if(password.toCharArray().length<5){ System.out.print(password); response.sendRedirect("register.jsp"); return false; } al.add(id); al.add(password); System.out.print("**注册成功**"); return true; } public boolean denglu(HttpServletRequest request, HttpServletResponse response) throws IOException { String id; String password; id=request.getParameter("ID"); password =request.getParameter("password"); if(id==null||id.equals("")){ response.sendRedirect("dengLu.jsp"); return false; } if(password.toCharArray().length<5){ response.sendRedirect("dengLu.jsp"); return false; } al.add(id); al.add(password); return true; } public boolean update(HttpServletRequest request, HttpServletResponse response) throws IOException { String id; String password; id=request.getParameter("ID"); password =request.getParameter("password"); if(id==null||id.equals("")){ response.sendRedirect("dengLu.jsp"); return false; } if(password.toCharArray().length<5){ response.sendRedirect("dengLu.jsp"); return false; } al.add(id); al.add(password); return true; } }
评论
    相关推荐
    • MVC架构模式详解
      通过一个动态计算单元格高度的工程代码,教你快速理解MVC架构模式,正确理解MVC结构模式
    • PureMVC架构
      一个自己学习PureMVC后做的ppt。 这个图应该对pureMVC架构做了一个很直白的描述。 希望对大家有所帮助。
    • MVC架构网站
      此项目使用VS2012编写运行 MVC架构 界面采用EXT类库实现之 js递归调用后台大量数据 代码编写经典 注释说明详细
    • pureMVC架构详细讲解
      公司内部培训文档,关于pureMVC架构的详细讲解,对于软件架构设计有一定指导意义。
    • flex_mvc架构
      flex mvc例子源码,非常不错,简单易懂。易于扩展。
    • MVC架构学士实例
      学习MVC架构的实例代码,有兴趣的朋友大家可以一起研究研究
    • JAVAEE MVC架构
      希望这个项目可以帮到大家,也很感谢这个平台能够给我们彼此互相学习,互相交流的机会!!!
    • MVC架构模板
      MVC架构模板,分层模板,包含数据库操作类
    • mvc架构网店jsp
      jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构jsp mvc架构
    • MVC架构demo
      MVC架构demo