学习练习 使用Servlet实现用户注册功能

package com.hanqi.www;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Test111 extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
   
    public Test111() {
        super();
        
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        response.setContentType("text/html");
        response.setCharacterEncoding("UTF-8");
        
        String us = request.getParameter("username");
        String pw = request.getParameter("password");
        String pw1 = request.getParameter("password1");
        //判断是否正确接收
                if(us != null && pw != null && pw1 != null)
                {
                    if(!us.equals(""))
                    {
                
                    if(pw.equals(pw1))
                    {
                        //记录用户信息
                        
                        //跳转到系统主页面
                        response.sendRedirect("Main.jsp");
                        
                    }
                    else
                    {
                        //否则就提示登录错误
                        response.getWriter().write("请输入相同的密码");
                    }
                    }
                    else
                    {
                        response.getWriter().write("帐号或密码不能为空字符串");
                    }
                }
                else
                {
                    response.getWriter().write("请正确输入您的信息");
                }
            
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        doGet(request, response);
    }

}

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


注册成功

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


注册页面

<% //销毁session session.invalidate(); %>
账户:
密码:
确认密码:

 

 

学习练习 使用Servlet实现用户注册功能_第1张图片

 

学习练习 使用Servlet实现用户注册功能_第2张图片

 

 

学习练习 使用Servlet实现用户注册功能_第3张图片

 

转载于:https://www.cnblogs.com/zhoudi/p/5633227.html

你可能感兴趣的:(学习练习 使用Servlet实现用户注册功能)