formdata.java

来自「j2EE」· Java 代码 · 共 48 行

JAVA
48
字号
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class FormData extends HttpServlet
{
	public void doGet(HttpServletRequest req ,HttpServletResponse res)throws ServletException, IOException
	{
		res.setContentType("text/html");
		PrintWriter out = res.getWriter();
		String name = req.getParameter("name");
		String dob = req.getParameter("dob");
		String sex = req.getParameter("sex");
		String id = req.getParameter("id");
		String address = req.getParameter("address");
		String phone = req.getParameter("phone");
		String email = req.getParameter("email");
		try{
			
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		  }
			catch(ClassNotFoundException ce)
			{
				out.println(ce);
			}
	
		try{
			Connection con = DriverManager.getConnection("jdbc:odbc:test5");
			Statement st = con.createStatement();
			int r = st.executeUpdate("insert into form values(' "+name+" ', ' "+dob+" ', ' "+sex+" ', ' "+id+" ', ' "+address+" ', ' "+phone+" ', ' "+email+" ')");
		}catch(SQLException se)
			{
				out.println(se.toString());
			}
			out.println("<HTML><BODY BGCOLOR = PINK><B> Your Application is accepted, and updated in the Database<br>After revision of your application and information you will be soon contacted through mail<br>Thanks!!</b>");
			out.println("<BR><BR><BR>Please Click Here to Log Out <a href = http://localhost/Login.html>Sign Out</a>");
			out.println("</Body></Html>");	 

		
	}
	
	public void doPost(HttpServletRequest req ,HttpServletResponse res)throws ServletException, IOException
	{
			doGet(req,res);
	}
}
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?