package fund.apply_pay_expenses;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.* ;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import include.nseer_db.*;
public class check_oka extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public check_oka() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* 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 synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession dbSession = request.getSession();
HttpSession session = request.getSession();
ServletContext dbApplication = dbSession.getServletContext();
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
nseer_db_backup1 sellsystem_db = new nseer_db_backup1(dbApplication);
String failing;
try{
if(sellsystem_db.conn((String)dbSession.getAttribute("unit_db_name"))){
String name=request.getParameter("name");//发送人
String time=request.getParameter("time");//发送时间
String message=request.getParameter("bio");//发送内容
String title=request.getParameter("title");
//String a=title+message+time; ---如果要想在主信息中插入多条信息,则可以相加其在插入。
//--------复选框----------
String phone=request.getParameter("cbxa");
String email=request.getParameter("email");//-----但选择邮件是获取邮件的地址
String inmessage=request.getParameter("cbxc");
String sql="insert into message(name,time,message,phone,email,inmessage,title) values('"+name+"','"+time+"','"+message+"','"+phone+"','"+email+"','"+inmessage+"','"+title+"')";
sellsystem_db.executeUpdate(sql);//执行sql
//System.out.println(sql);
int i=sellsystem_db.getState();
if (i > 0) {
failing ="{success:true, file:'成功'}";
} else {
failing ="{success:true, file:'失败'}";
}
out.print(failing);
}else{
response.sendRedirect("error_conn.htm");
}
sellsystem_db.commit();
}catch (Exception ex){
ex.printStackTrace();
}finally{
try{
sellsystem_db.close();
}catch(Exception e){
e.printStackTrace();
}
}
//out.flush();
//out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
servlet中的代码
最新推荐文章于 2023-02-27 15:52:51 发布