该源码为JSP的开发案例集锦
源代码在线查看: add.jsp
保存留言
String name=request.getParameter("name");
name=new String(name.getBytes("8859_1"));
String title=request.getParameter("title");
title=new String(title.getBytes("8859_1"));
String content=request.getParameter("content");
content=new String(content.getBytes("8859_1"));
String mail=request.getParameter("mail");
mail=new String(mail.getBytes("8859_1"));
Class.forName("org.gjt.mm.mysql.Driver");
String dbUrl = "jdbc:mysql://localhost/csnews";
String dbUser = "root";
String dbPassword = "";
Connection con = DriverManager.getConnection(dbUrl,dbUser,dbPassword);
Statement stm=con.createStatement();
String sql="insert into message values('"+title+"','"+name+"','"+content+"','"+
mail+"','" + new java.util.Date() + "')";
if(stm.executeUpdate(sql)==1)
else
out.print("添加失败");
con.close();
%>