<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="lyxianshi.jsp" method="post">
ID: <input type="text" name="name">
<br>
回复:<textarea name="testarea" ></textarea>
<br>
<input type="submit" value="提交">
</form>
</body>
</html>
![复制代码](//assets.cnblogs.com/images/copycode.gif)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
String testarea=new String(request.getParameter("testarea").getBytes("ISO-8859-1"),"UTF-8");
Connection conn = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String strUrl = "jdbc:oracle:thin:@localhost:1521:orcl" ;
conn = DriverManager.getConnection(strUrl, "test", "5211314");
System.out.println("连接数据库成功!");
Statement st = conn.createStatement();
st.executeUpdate("insert into liuyan values( ly.nextval,'"+name+"','"+testarea+"')");
ResultSet rs= st.executeQuery("select * from liuyan order by ly");
while(rs.next())
{
String id= rs.getString(2);
String liuyan= rs.getString(3);
%>
<table width="100%" border="1">
<tr height="20" ><td>id:<%=id %></td></tr>
<tr height="40" ><td>留言:<%=liuyan %></td></tr>
</table>
<%--out.print("<br>id:"+ id + " 留言:"+liuyan );--%>
<%
}
rs.close();
st.close();
conn.close();
}
catch (Exception e)
{
// TODO 自动生成的 catch 块
e.printStackTrace();
}
%>
</body>
</html>
![复制代码](//assets.cnblogs.com/images/copycode.gif)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165834031-168209523.png)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165858938-279924027.png)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165916078-789253934.png)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165934063-727871493.png)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165945922-1576022366.png)
![](https://images2015.cnblogs.com/blog/917851/201606/917851-20160626165954438-851343420.png)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步