📄 person.java
字号:
package sas;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.*;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import java.sql.* ;
import java.sql.Date;
import java.text.*;
public class person extends HttpServlet {
/**
* Constructor of the object.
*/
public person() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GB2312");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect;
connect=DriverManager.getConnection("jdbc:odbc:BankDataSource","sa","123456");
Statement state;
String update;
state = connect.createStatement();
String Register_ID=(String) request.getSession(true).getAttribute("Register_ID");
request.setCharacterEncoding("utf-8");
update="update Ac_Requests set Address='"+request.getParameter("Address")+"', State='"+request.getParameter("State")
+"',Zip='"+request.getParameter("Zip")+"',E_Mail='"+request.getParameter("E_Mail")
+"',Home_Phone='"+request.getParameter("Home_Phone")+"' where Register_ID='"+Register_ID+"'";
state.executeUpdate(update);
state.close();
connect.close();
request.getSession(true).setAttribute("Address",request.getParameter("Address"));
request.getSession(true).setAttribute("State",request.getParameter("State"));
request.getSession(true).setAttribute("Zip",request.getParameter("Zip"));
request.getSession(true).setAttribute("E_Mail",request.getParameter("E_Mail"));
request.getSession(true).setAttribute("Home_Phone",request.getParameter("Home_Phone"));
}
catch(SQLException Sqle){
Sqle.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
request.getRequestDispatcher("Home_page.htm").forward(request,response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -