编写一个简易的留言薄,实现添加留言和显示留言内容的功能
2016-06-27 09:07
666 查看
<%@ 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>
<%@ 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>
相关文章推荐
- 字体使用sp、dp的区别
- mac OpenGL 开发环境搭建
- [转]Java 常用排序算法/程序员必须掌握的 8大排序算法
- 鼠标悬浮时发生的效果改变
- html+css3实现精美导航
- ASP.NET MVC+Bootstrap个人博客之修复UEditor编辑时Bug(四)
- C#标准响应数据
- Java hashCode的重要性
- <幼儿园数学>数列递推<一>
- 分布式一致性算法--Paxos
- [李景山php]每天laravel-20160908|Dispatcher-8
- Linux(Centos)之安装tomcat并且部署Java Web项目(转)
- HTML基础做出属于自己的完美网页
- 【Arduino官方教程第一辑】示例程序 6-3 Memsic2125加速度计
- [李景山php]每天laravel-20160908|Dispatcher-8
- 13 继续C#中的方法,带返回值的方法介绍
- ExtJS6图表简单demo(折线图,散点图,柱状图)
- jQuery实现点击网页内按钮,实现网页内灯光的亮灭
- monkey test备忘
- Java 基于多客户端的ServerSocket—聊天服务器端,客户端Socket “操作文件”系统的程序拼接