📄 sort.jsp
字号:
<%
/**
* $RCSfile: sort.jsp,v $
* $Revision: 1.0 $
* $Author: Bruce $
* $Date: 2001/4/10$
*/
%>
<%@ page
import="java.util.*,
java.text.*,
java.net.*,
java.sql.*,
com.coolservlets.forum.*,
com.coolservlets.forum.util.*,
com.everstar.bbs.*"
errorPage="error.jsp"
%>
<%! // Global variables
//declare a new DbMessageCount object
DbMessageCount dbMessageCount = new DbMessageCount();
// Method to print the Hot List
private String displayHotList( int index ,String name,String userName,String email,String postedCount) {
StringBuffer buf = new StringBuffer();
if( name == null || name.equals("") ) {
name = "[no register]";
}
// score cell
buf.append("<td width='1%' nowrap align='center'>");
buf.append("<font size='-1' color='#666666' face='verdana' size='2'>");
buf.append(index);
buf.append("</font></td>");
// name cell
buf.append("<td width='1%' nowrap align='center'>");
buf.append("<font size='-1' color='#666666' face='verdana' size='2'>");
buf.append(name);
buf.append("</font></td>");
// username cell
buf.append("<td width='1%' nowrap align='center'>");
buf.append("<font size='-1' color='#666666' face='verdana' size='2'>");
buf.append(userName);
buf.append("</font></td>");
// e_mail cell
buf.append("<td width='1%' nowrap align='center'>");
buf.append("<font size='-1' color='#666666' face='verdana' size='2'>");
buf.append("<a href='mailto:");
buf.append(email);
buf.append("'>");
buf.append(email);
buf.append("</font></td>");
// posted messages cell
buf.append("<td width='1%' nowrap align='center'>");
buf.append("<font size='-1' color='#666666' face='verdana' size='2'>");
buf.append(postedCount);
buf.append("</font></td>");
return buf.toString();
}
%>
<% ////////////////////////
// Authorization check
// check for the existence of an authorization token
Authorization authToken = SkinUtils.getUserAuthorization(request,response);
// if the token was null, they're not authorized. Since this skin will
// allow guests to view forums, we'll set a "guest" authentication
// token
if( authToken == null ) {
authToken = AuthorizationFactory.getAnonymousAuthorization();
}
%>
<% // get parameters
int forumID = ParamUtils.getIntParameter(request, "forum", -1);
%>
<% ForumThread thread = null;
Forum forum = null;
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
String forumName= "Whole of the Forum"; //the default forumName
if (forumID!= -1){ //if isn't "All of the Forum"
try {
forum = forumFactory.getForum(forumID); // throws ForumNotFoundException
}
catch( UnauthorizedException ue ) {
response.sendRedirect( "error.jsp?message=" + URLEncoder.encode("You don't have access to view this forum.") );
return;
}
catch( ForumNotFoundException fnfe ) {
response.sendRedirect( "error.jsp?message=" + URLEncoder.encode("Can't view a forum that doesn't exist.") );
return;
}
forumName = forum.getName();
}
Iterator forumIterator = forumFactory.forums();
%>
<% /////////////////
// header include
String title = forumName;
%>
<%@ include file="header.jsp" %>
<%-- begin breadcrumbs
<form>
<font face="verdana" size="2"><b><a href="index.jsp" class="normal">Home</a>
></b>
<font size=2><b>
<select name="forumName" size=1 class="breadcrumbBox" onchange="location=this.options[this.selectedIndex].value;">
<option value="" selected><%= forumName %>
<option value="sort.jsp?forum=<%= forumID %>">-----------------
<option value="sort.jsp?forum=-1">Whole of the Forum
<% while (forumIterator.hasNext()) {
Forum tmpForum = (Forum)forumIterator.next();
String name = tmpForum.getName();
String location = "sort.jsp?forum=" + tmpForum.getID();
%>
<option value="<%= location %>">> <%= name %>
<% }
%>
</select>
</b></font>
</font>
</form>
end breadcrubms --%>
<%-- begin breadcrumbs --%>
<form>
<table>
<tr>
<td align="left" width="20" > <b><a href="index.jsp" class="normal">
<font face="verdana" size="2">Home</a>></font>
</b> </td>
<td align="left" width="40%" nowrap> <b>
<font size=2>
<select name="forumName" size=1 class="breadcrumbBox" onchange="location=this.options[this.selectedIndex].value;">
<option value="" selected><%= forumName %>
<option value="sort.jsp?forum=<%= forumID %>">-----------------
<option value="sort.jsp?forum=-1">Whole of the Forum
<% while (forumIterator.hasNext()) {
Forum tmpForum = (Forum)forumIterator.next();
String name = tmpForum.getName();
String location = "sort.jsp?forum=" + tmpForum.getID();
%>
<option value="<%= location %>">> <%= name %>
<% }
%>
</select></font></b></td>
<td align="right" width="195" nowrap><b>
<font face="verdana" size="5">Hot List</font> </a>
</b> </td>
</tr>
</table>
</form>
<%-- end breadcrubms --%>
<table bgcolor="#999999" cellpadding=0 cellspacing=0 border=0 width="100%">
<td>
<table bgcolor="#999999" cellpadding=3 cellspacing=1 border=0 width="100%">
<tr bgcolor="#dddddd">
<td align="center" width="1%" nowrap><font size="1" face="tahoma,arial,helvetica">score</font></td>
<td align="center" width="1%" nowrap><font size="1" face="tahoma,arial,helvetica">name</font></td>
<td align="center" width="1%" nowrap><font size="1" face="tahoma,arial,helvetica">userName</font></td>
<td align="center" width="1%" nowrap><font size="1" face="tahoma,arial,helvetica">e_mail</font></td>
<td align="center" width="1%" nowrap><font size="1" face="tahoma,arial,helvetica">posted messages</font></td>
</tr>
<% int rowColor = 0;
String bgcolor = "";
/*if(forumID==-1){
sortList = dbMessageCount.getSort();
}else{
sortList = dbMessageCount.getSort(forumID);
}*/
Properties sortList = dbMessageCount.getSort(forumID); //Get the Result of Sort
int index=0;
//display the first ten hot list
Vector sortListLine = new Vector();
while(!sortList.isEmpty() && index<10) {
index++;
//sortListLine=sortList.get(new Integer(index));
sortListLine = (Vector)sortList.remove(new Integer(index));
String name = (String)sortListLine.get(0); //"name"
String userName = (String)sortListLine.get(1); //"userName"
String email = (String)sortListLine.get(2); //"email"
String postedCount = (String)sortListLine.get(3); //postedCount
if( index%2 == 0 ) {
bgcolor = "#ffffff";
} else {
bgcolor = "#eeeeee";
}
%>
<tr bgcolor="<%= bgcolor %>">
<%= displayHotList(index,name,userName,email,postedCount)%>
</tr>
<% } %> <!--end of while -->
</table>
</td>
</table>
<br>
<%@ include file="footer.jsp" %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -