概述
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中的代码的全部内容,希望文章能够帮你解决servlet中的代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复