注册页面
注册页面的java代码
package org.sjl;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.snn.util.DBHelper;
public class RegServelt extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
// 设置响应格式
response.setContentType("text/html");
// 接收请求中的参数
String name = request.getParameter("name");
String paw = request.getParameter("paw");
boolean isTrue = false;
Connection conn = DBHelper.getConn();
String sql = "insert into student (name,paw) values(?,?)";
System.out.println("mmmm");
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, paw);
// 用int接收数据
int count = ps.executeUpdate();
if (count > 0) {
// 注册成功
isTrue = true;
} else {
isTrue = fal