JAVA实验用户登录代码

上传人:鲁** 文档编号:426934375 上传时间:2022-08-09 格式:DOC 页数:7 大小:46.51KB
返回 下载 相关 举报
JAVA实验用户登录代码_第1页
第1页 / 共7页
JAVA实验用户登录代码_第2页
第2页 / 共7页
JAVA实验用户登录代码_第3页
第3页 / 共7页
JAVA实验用户登录代码_第4页
第4页 / 共7页
JAVA实验用户登录代码_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《JAVA实验用户登录代码》由会员分享,可在线阅读,更多相关《JAVA实验用户登录代码(7页珍藏版)》请在金锄头文库上搜索。

1、实验结果部分截图:(1)错误的用户名密码(2)错误提示页(3)正确的用户名密码(4)成功页面实验代码:Login部分:import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class Login e

2、xtends HttpServlet /* * Constructor of the object. */public Login() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value met

3、hod 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, HttpServletRespons

4、e response)throws ServletException, IOException response.setContentType(text/html);response.setCharacterEncoding(gb2312);PrintWriter out = response.getWriter();out.println();out.println();out.println();out.println(A Servlet);out.println( );out.print();out.print();out.println(用户名:);out.println();out.

5、println();out.println();out.println(密码:);out.println();out.println();out.println();out.println();out.println(            );out.println();out.println();out.println();out.println();out.flush();out.close();/* * The doPost method of the servlet

6、. * * 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 */pu

7、blic void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);/* * Initialization of the servlet. * * throws ServletException if an error occurs */public void init() throws ServletException / Put your code hereLoginuser部分:impo

8、rt java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class Loginuser extends HttpServlet /* * Constructor of the object. */public

9、 Loginuser() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send b

10、y 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 */* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. *

11、* 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 Se

12、rvletException, IOException User newUser = new User();newUser.userName = request.getParameter(ID_USER);newUser.passWord = request.getParameter(ID_PASS);response.setContentType(text/html);response.setCharacterEncoding(utf-8);PrintWriter out = response.getWriter();out.println();out.println();out.println( A Servlet);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 机械/制造/汽车 > 汽车技术

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号