⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showboard.jsp

📁 机械工业出版社的《jsp2.0动态网站开发实例指南》的源代码
💻 JSP
字号:
<!--showboard.jsp-->
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%!
	public String codeString(String s){
		String str=s;
                try{
			byte b[]=str.getBytes("ISO-8859-1");
			str=new String (b);
			return str;
		}catch(Exception e){return str;}
	}
%>
<html>
<head>
<title>Board</title>
</head>
<body bgcolor=#C0C0C0>
<center><h1>公共留言</h1>
<%
	try{
		String title;
		String time;
		String message;
		String fromid; 
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con=DriverManager.getConnection("jdbc:odbc:board","","");
		Statement sql=con.createStatement();
		String condition="SELECT * FROM board ";
		ResultSet rs=sql.executeQuery(condition);
		int rowcount=0;
		String temp=request.getParameter("rowcount");
		int rc=1;
		try{
			rc=(Integer.valueOf(temp)).intValue();
		}
		catch(NumberFormatException e){
			response.sendRedirect("board.jsp");
		}
		while(rs.next()){
			rowcount++;
			if(rowcount==rc){
				title=rs.getString("title");
				time=rs.getString("time");
				message=rs.getString("message");
				fromid=rs.getString("fromid");
				%>
				<center>
				<br>
				<br>
				<table width="500" border="1">
				<tr>
					<td width="100">标题</td>
					<td width="400"><%=title%></td>
				</tr>
				<tr>
					<td width="100">时间</td>
					<td width="400"><%=time%></td>
				</tr>
				<tr>
					<td width="100">作者</td>
					<td width="400"><%=fromid%></td>
				</tr>
				<tr>
					<td width="100">内容</td>
					<td width="400"><%=message%></td>
				</tr>
				</table>
				</center>
			<%
			}
		}
		%>
		<%
		con.close();
	}catch(SQLException e){
		%>
		<jsp:forward page="index.jsp"/>
		<%
	}catch(ClassNotFoundException e){
		%>
		<jsp:forward page="index.jsp"/>
		<%
	}

%>
<a href="board.jsp">返回</a>
</center>
</body>
</html>

⌨️ 快捷键说明

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