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

📄 board.jsp

📁 机械工业出版社的《jsp2.0动态网站开发实例指南》的源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="shop.logBean"%>
<%@ 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>Shop</title>
</head>
<body bgcolor=#C0C0C0>
<center>
<%
	if(session.isNew()){
		%>
		<jsp:forward page="index.jsp"/>
		<%
	}
	else {
		%>
		<jsp:useBean id="log" class="shop.logBean" scope="session"/>
		<%
		String islog=log.getIslog();
		if(!islog.equals("true")){
			%>
			<jsp:forward page="index.jsp"/>
			<%
		}
		else{
			%>
			<center>
			<jsp:getProperty name="log" property="id"/>
			,公共留言列表
			<%
			if(log.getId().equals("admini")){
				%>
				<jsp:include page="adminihead.txt"/>
				<%
			}
			else{	
				%>
				<jsp:include page="head.txt"/>
				<%
			}
			%>
			</center>
			<%
			try{
     				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  				Connection con;
  				Statement sql;
  				ResultSet rs;
  				String title;
  				String time;
  				//String message;
  				String fromid; 
     				con=DriverManager.getConnection("jdbc:odbc:myshop","","");
     				sql=con.createStatement();
    				String condition="SELECT * FROM board ";
      				rs=sql.executeQuery(condition);
      				int rowcount=0;
      				%>
      				<center>
      				<table width="800" >
      				<tr>
				<td ><table border="1" width="800" height="30">
				<td width="400" valign="middle" align="center">时间</td>
				<td width="100" valign="middle" align="center">作者</td>
				<td width="300" valign="middle" align="center">标题</td>
				</table></td>
				</tr>
      				<%
    				while(rs.next()){
       					rowcount++;
      					time=rs.getString("time");
      					fromid=rs.getString("fromid");
      					title=rs.getString("title");
      					//message=rs.getString("message");
      					//time="time";
      					//fromid="fromid";
      					//title="title";
  					%>
  					<tr>
					<td><table  border="1" width="800" height="30">
					<td width="400" valign="middle" align="center"><%=time%></td>
					<td width="100" valign="middle" align="center"><%=fromid%></td>
					<td width="300" valign="middle" align="center"><a href="showboard.jsp?rowcount=<%=rowcount%>"><%=title%></a></td>
					</td>
					</table></td>
					</tr>
  					<%
      				}
      				%>
      				</table>
      				<a href="addboard.jsp">我也留言</a>
      				</center>
      				<%
      				con.close();
      			}catch(SQLException e){
      				%>
  				<jsp:forward page="index.jsp"/>
  				<%
      			}catch(ClassNotFoundException e){
  				%>
  				<jsp:forward page="index.jsp"/>
  				<%
  			}
		}
	}
%>
</center>
</body>
</html>

⌨️ 快捷键说明

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