1.建立工程
File->new->Project->Web Project,假如起名Register1。在其scr中建立class类(右键scr->New->Class),Package(包名):mywork.test。Name:RegisterServlet。finish。
2.RegisterServlet.java中代码
File->new->Project->Web Project,假如起名Register1。在其scr中建立class类(右键scr->New->Class),Package(包名):mywork.test。Name:RegisterServlet。finish。
2.RegisterServlet.java中代码
package mywork.test;
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;
import java.sql.*;
public class RegisterServlet extends HttpServlet {
static{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("into Servlet!!");
// get data
String username