永发信息网

JSP网页制作

答案:2  悬赏:60  手机版
解决时间 2021-04-13 03:43
我想要用JSP做的带有留言版的网页代码、 最好是现成的那种 急求··
最佳答案

简单的就有


<%--
Document : checkDB
Created on : 2009-11-1, 23:21:46
Author : Administrator
--%>


<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
" http://www.w3.org/TR/html4/loose.dtd">
<%
int dipage = 1;
String pages = request.getParameter("dipage");
if (pages == null) {
pages = "1";
}
try {
dipage = Integer.parseInt(pages);
} catch (Exception e) {
dipage = 1;
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");


try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=ming", "min", "123");


Statement stmt = con.createStatement();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("select * from liuyan order by time desc");
int countRecord = 0;
int i = 0;
int countPageRecord = 0;
int countPage = 1;
countPageRecord = 5;
rs.last();
countRecord = rs.getRow();
if (countRecord / countPageRecord == 0) {
countPage = countRecord / countPageRecord;
} else {
countPage = countRecord / countPageRecord + 1;
}
if ((dipage - 1) * countPageRecord == 0) {
rs.beforeFirst();
} else {
rs.absolute((dipage - 1) * countPageRecord);
}



%>
<% while (rs.next()) {%>
<p> <table border="0">


<tbody>
<tr>
<td><img src="d:\我的文档\桌面\tian\image\9809.jpg"/>
</td>
<td > &nbsp; &nbsp; &nbsp;</td>
<td>主题:<%=rs.getString(4)%></td>
</tr>
<tr>



<td>姓名:<%=rs.getString(2)%></td>
<td > &nbsp; &nbsp; &nbsp;</td>
<td > 内容:</td>
</tr>
<tr>
<td>E-mail:<%=rs.getString(3)%></td>
<td > &nbsp; &nbsp; &nbsp;</td>
<td width="150"><%=rs.getString(5)%></td>
</tr>
</tbody>
</table></p>
--------------------------------------------------------
<%
i++;
if (i >= countPageRecord) {
break;
}
}
out.print("共" + countRecord + "条记录,共" + countPage + "页,当前第" + dipage + "页,每页" + countPageRecord + "条记录");
if (dipage == 1); else {
out.print("<a href=showly.jsp?dipage=1>首页</a>,");
out.print("<a href=showly.jsp?dipage=" + (dipage - 1) + ">上一页</a>,");
}
if (dipage == countPage) {
;
} else {
out.print("<a href=showly.jsp?dipage=" + (dipage + 1) + ">下一页</a>,");
out.print("<a href=showly.jsp?dipage=" + countPage + ">末页</a>");


}
out.print("<tr>");


rs.close();
stmt.close();
con.close();
} catch (Exception e) {
out.println("数据库异常");
}
%>
<form name="liuyanban" action="mas_saves.jsp" method="POST">
<table border="0">


<tbody>
<tr>
<td>留言人:</td>
<td><input type="text" name="lname" value="" /></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="text" name="Email" value="" /></td>
</tr>
<tr>
<td>留言主题:</td>
<td><input type="text" name="zhuti" value="" /></td>
</tr>
<tr>
<td>留言信息:</td>
<td></td>
</tr>


</tbody>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea name="neirong" rows="5" cols="35">
</textarea>
<table border="0">


<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="提交" name="tijiao" /></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="关闭" name="close" /></td>
</tr>
</tbody>
</table>
</form>
<%
out.print("<form action=check.jsp method=post>");
out.print("<input type=submit value=返回></form>");%>
</body>
</html>
mas_saves.jsp


<%--
Document : mas_saves
Created on : 2009-11-5, 23:03:00
Author : Administrator
--%>


<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.Date" %>
<!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>留言板</title>
</head>
<body>
<%!


public String codeToString(String str)
{
String s=str;
try{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e){
return s;
}
}
%>
<%
request.setCharacterEncoding("UTF-8");


try{
String name=request.getParameter("lname");
String Email=request.getParameter("Email");
String zhuti=request.getParameter("zhuti");
String neirong=request.getParameter("neirong");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=ming", "min", "123");
Statement stmt=con.createStatement();
stmt.execute("insert into liuyan (time,lname,email,tops,neirong)"+ "values(getdate(),'"+name+"','"+Email+"','"+zhuti+"','"+neirong+"')");
out.println("留言成功");


response.setHeader("refresh","1;url=showly.jsp");
con.close();
}
catch(SQLException e )
{
out.println("数据库异常");

}
%>
</body>
</html>

全部回答
你找一本带案例的JSP教程就行了!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
你做过用手指记数的游戏吗?一个小朋友按如图
叠词:XX动听快点我很着急!
听说今年各大院校会提前放寒假,是否属实?
现在有没有手机可以超快速充电的,能几分钟充
日本麻将的听牌到底是怎么听的说?
我的狗去医院检查了细小。吃了点消炎药到现在
笔记本具有什么样的配置算比较好的?运行起来
美国首先研制出原子弹的原因不包括(  )A.国
生活是一种态度名言,奶爸的爱情生活有句台词
致青春主题烤吧在什么地方啊,我要过去处理事
数控加工中心各种刀具的代码是怎样的?
三星厨卫蓝田专卖店地址有知道的么?有点事想
QQ三国怎么解屏啊!?速速!
兰州交通大学、桂林电子科技大学、昆明理工大
无线鼠标电池怎么安装,无线鼠标怎么连接TCL电
推荐资讯
图3所示的书被誉为“东方医学的巨典”。它的
刷分会被发现会怎么样??
呼吸道感染不适吃什么?
电影作为一种新艺术得以成立,其成立的条件和
老款奥迪A3还没出保刹车异响,如何解决?
Mr. Black,We're very gladly to have receiv
哪有中文的 重装奇兵2 和 模拟器 下载
输尿管结石吃什么样的排石颗粒最好?
求一个自动注入dll的工具,我急用
qq自由幻想怎么点亮呢
谁知道西工大自在广场英语闫老师的电话?跪求
我喜欢她,现在怎么办
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?