<%@ page import="java.util.*, java.text.*, com.coolservlets.forum.*, com.coolservlets.forum.util.*" errorPage="error.jsp" %> <% // get parameters boolean logout = ParamUtils.getBooleanParameter(request, "logout"); int forumID = ParamUtils.getIntParameter(request, "forum", -1); long lastVisited = SkinUtils.getLastVisited(request, response); %> <% // logout if requested: if (logout) { SkinUtils.removeUserAuthorization(request, response); response.sendRedirect("index.jsp"); return; } %> <% //////////////////////// // 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 a forum factory and forum iterator ForumFactory forumFactory = ForumFactory.getInstance(authToken); Iterator forumIterator = forumFactory.forums(); %> <% ///////////////// // header include String title = "Forum home page"; %> <%@ include file="header.jsp" %>

<%-- recent dicussions --%> <%-- end recent dicussions --%>
<%-- begin main content --%>

Forum home page

<% // check to see if there are no forums if( !forumIterator.hasNext() ) { %>
    No forums in the system, or you don't have permission to view forums.
<% } else { %> <% while( forumIterator.hasNext() ) { Forum forum = (Forum)forumIterator.next(); int id = forum.getID(); String name = forum.getName(); String description = forum.getDescription(); int numThreads = forum.getThreadCount(); int numMessages = forum.getMessageCount(); long lastModified= forum.getModifiedDate().getTime(); %> <% } %>
<% if (lastModified > lastVisited) { %> <% } else { %> • <% } %> <%= name %> (<%= description %>)
(<%= numThreads %> <%= (numThreads==1) ? " thread" : " threads" %>, <%= numMessages %> <%= (numMessages==1) ? " message" : " messages" %>)
<% } %> <%-- end main content --%>

<%@ include file="footer.jsp" %>