jsp11

2021-01-19 01:23

阅读:624

YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

标签:size   override   form   templates   tool   sp1   ram   成功   title   

$Title$
用户名:
密码 :
验证码 :

   

注册新用户请单击此处
技术图片
技术图片


Title
用户名:

密   码:

邮   箱:

   
技术图片
技术图片
package Servlet;

import JDBC.JDBC;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

@WebServlet(name = "LoginServlet")
public class RegisterServlet extends HttpServlet {
    public RegisterServlet() {
        super();
    }

    @Override
    public void destroy() {
        super.destroy();
    }
    public void wrong1() {
        String msg = "注册成功!";
        int type = JOptionPane.YES_NO_OPTION;
        String title = "信息提示";
        JOptionPane.showMessageDialog(null, msg, title, type);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        JDBC jdbc = new JDBC();
        Connection con = null;
        PreparedStatement ps = null;
        String username=new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF-8");
        String PASSWORD=new String(request.getParameter("userpassword").getBytes("ISO-8859-1"),"UTF-8");
        String email=new String(request.getParameter("Email").getBytes("ISO-8859-1"),"UTF-8");
        try {
            con = jdbc.getConnection();
            String sql = "insert into users(username,PASSWORD,email) values (?,?,?)";
            ps = con.prepareStatement(sql);
            ps.setString(1, username);
            ps.setString(2,PASSWORD);
            ps.setString(3, email);
            int row = ps.executeUpdate();
            wrong1();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            jdbc.closeAll(con,ps,null);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
技术图片
技术图片
RegisterServlet/RegisterServletRegisterServletServlet.RegisterServlet

jsp11

标签:size   override   form   templates   tool   sp1   ram   成功   title   

原文地址:https://www.cnblogs.com/akaxuan/p/13338631.html


评论


亲,登录后才可以留言!