pinglun.jsp

来自「jsp做的一个个人网站」· JSP 代码 · 共 42 行

JSP
42
字号
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p align="left">对文章发表评论:</p>
  <p align="left">
    <textarea name="pinglun" cols="60"></textarea>
    </p>
  
</form>
<table align="center" width="780">

<%  
 request.setCharacterEncoding("gb2312");
 String id=request.getParameter("id"); 
String pinglun=request.getParameter("pinglun"); 
if(pinglun==null){ }
else{

String publisher=(String)session.getAttribute("customer");
String publishdate=new java.text.SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒").format(new java.util.Date());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:test","sa","sa");


String sql="insert into pinglun(username,content,publishdate)values('"+publisher+"','"+pinglun+"','"+publishdate+"')";
//String sql="insert into wenzhang(timu,zuozhe,neirong,shijian)values('title','asas',cont','publishdate')";
Statement stmt=con.createStatement();
stmt.executeUpdate(sql);
con.close();
}%>


 </table>
</body>
</html>

⌨️ 快捷键说明

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