Demo entry 6359417

jsp

   

Submitted by anonymous on Apr 28, 2017 at 09:16
Language: Java Server Page. Code size: 5.3 kB.

<%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@page import="java.sql.Date"%>
<jsp:useBean id="db" class="yh.db" scope="page"/>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
   <link style="text/css" rel="stylesheet" href="css/common.css">
    <%@ include file="config.jsp"  %>
    <title><%=config_forumsname %></title>
  </head>

<body background="images/bg.png">


    

    
    <div id="head">
    	<center><img src="images/logo.png" width=50% height=100/></center>
    	<br>
    	
    	<%
    		if(session.getAttribute("username")!=null)//有账号登录
    		{
    			%>
				<div align="right">
					<a href="index.jsp"><%=sy %></a><!-- 首页 ,跳转本业-->
    				<a href="logout.jsp"><%=tc %></a><!-- 退出 ,跳转退出页面-->
    				<a href="newtopic.jsp"><%=xzt %></a><!-- 新主题,跳转新主题页面 -->
    				<a href="javascript:void(0);" onClick="this.style.behavior='url

(#default#homepage)';this.setHomePage(location.href)" class="white">设为首页</a>
    				</div>
    				<%
    		}
    		else{//没有账号
    			%>
    			
				<div align="right">
					<a href="index.jsp"><%=sy %></a>
    				<a href="admin_or_user.jsp"><%=dl %></a>
    				<a href="register.jsp"><%=zc %></a>
    				<a href="newtopic.jsp"><%=xzt %></a>
    				<a href="javascript:void(0);" onClick="this.style.behavior='url

(#default#homepage)';this.setHomePage(location.href)" class="white">设为首页</a>
    				</div>

			<%
    		}
    	 %>
    	
	 </div>
	 <hr >
	 <div id="main">

	<br>
	  <%
	request.setCharacterEncoding("utf-8");
   String catsql="select * from categories;";//类别
   
   ResultSet catresult=db.exeSqlQuery(catsql);
   
%>
<table id="table1">
		<%
			while(catresult.next()){
				%>
				
				<tr class="head">
					<td bgcolor="#A6FFA6" ><strong><img src="images/bt.png" height="50"><%=catresult.getString("name") %></strong></td><%--从数据库得到板块类别 --%>
					<td bgcolor="#A6FFA6" align="center"><strong><%=zjhf %></strong></td><%--最近回复 --%>
				</tr>
				
				
				<%
				String forumsql="select * from forums where cat_id='"+catresult.getString("id")+"';";
				ResultSet forumresult=db.exeSqlQuery(forumsql);
				forumresult.last();
				int forumnumber=forumresult.getRow();
				System.out.println("wo"+forumnumber);
				if(forumnumber==0){
					%>
					<tr><td>还没有添加模块</td></tr>
					<%
					}
				else{
				    forumresult.beforeFirst();
					while(forumresult.next()){
					String yhhsql="select * from topics where forum_id="+forumresult.getInt("id")+";";
					ResultSet yhhresult=db.exeSqlQuery(yhhsql);
					yhhresult.next();
					
					if(yhhresult.isFirst()){
					String sql="select messages.date,topics.subject,users.username from messages,topics,users where messages.topic_id=topics.id and messages.user_id=users.id and topics.forum_id="+forumresult.getInt("id")+" order by messages.date desc;";
					System.out.println(sql);
					ResultSet yanghao=db.exeSqlQuery(sql);
					if(yanghao!=null){
					yanghao.first();
					String yh=yanghao.getString("topics.subject");
					if(yh.length()>15){
					yh=yh.substring(0,14);
					yh=yh+"......";}
					System.out.println("杨颢"+yh);
						%>
						<tr>
						<td width=70%><strong><a href="viewforum.jsp?id=<%=forumresult.getString("id") %>"><%=forumresult.getString("name") %></a></strong><br><p><%=forumresult.getString("description") %></p></td>
						<td align="center" width=30%><%=yh %><br><font color="#D94600"><%=yanghao.getString("users.username") %></font>&nbsp;<%=yanghao.getDate("messages.date") %></td>
						</tr>
						<tr><td><hr color="#EFFFD7"></td><td><hr color="#EFFFD7"></td></tr>
						<%
						
					}else{
						%>
						<tr>
						<td width=70%><strong><a href="viewforum.jsp?id=<%=forumresult.getString("id") %>"><%=forumresult.getString("name") %></a></strong><br><p><%=forumresult.getString("description") %></p></td>
						<td align="center" width=30%>还没有主题哦,快快发表自己的见解吧!</td>
						</tr>
						<tr><td><hr color="#EFFFD7"></td><td><hr color="#EFFFD7"></td></tr>
						<%
					}
					}else{
						%>
						<tr>
						<td width=70%><strong><a href="viewforum.jsp?id=<%=forumresult.getString("id") %>"><%=forumresult.getString("name") %></a></strong><br><p><%=forumresult.getString("description") %></p></td>
						<td align="center" width=30%><%="还没有主题哦,快快发表自己的见解吧!" %></td>
						</tr>
						<tr><td><hr color="#EFFFD7"></td><td><hr color="#EFFFD7"></td></tr>
							
						<%
					}
					}
				
				}
			}
			
		 %>
		
		 
	</table>
     </div>

	<br>
	
	
	<!--  <center>友情链接:&nbsp;<a href="http://www.sxau.edu.cn/">山西农业大学</a>
	&nbsp;&nbsp;<a href="http://0x9.me/aVKY4">山西农业大学吧</a>
	&nbsp;&nbsp;<a href="http://0x9.me/4YphR">山西农业大学交易兼职集散中心</a>
	&nbsp;&nbsp;<a href="http://jwc.sxau.edu.cn/jyjx/xsmd/xxkxygcxy.htm">信息科学与工程学院</a>
	&nbsp;&nbsp;<a href="http://www.baidu.com/index.php">百度搜索</a></center>-->
	
	<%@ include file="foot.jsp"%>
	
  </body>


  <style type="text/css">
#table1{
	margin-left:100px;
 	width: 80%;
 	border: NONE;
 	border-collapse: collapse;
 	}
 	</style>
 	</html>

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).