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

📄 _viewthread__jsp.java

📁 JSP聊天系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*
 * JSP generated by Resin 2.1.4 (built Fri Aug  2 14:16:52 PDT 2002)
 */

package _forum;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.text.*;
import com.coolservlets.forum.*;
import com.coolservlets.forum.util.*;
import java.util.Date;
import java.text.SimpleDateFormat;

public class _viewthread__jsp extends com.caucho.jsp.JavaPage{
  private boolean _caucho_isDead;
  	////////////////
	// global variables
	SimpleDateFormat dateFormatter 
		= new SimpleDateFormat("EEE, MMM d '于' hh:mm:ss");
	
	/**
	 * Print a child message
	 */
	private String printChildMessage( Forum forum, ForumThread thread, ForumMessage message, int indentation, String mode )
	{
		StringBuffer buf = new StringBuffer();
		try {
		if( mode.equals("flat") ) {
			indentation = 0;
		}
		String subject = message.getSubject();
		boolean msgIsAnonymous = message.isAnonymous();
		User author = message.getUser();
		String authorName = author.getName();
		String authorEmail = author.getEmail();
		String userName = author.getUsername();
		int forumID = forum.getID();
		int threadID = thread.getID();
		int messageID = message.getID();
		Date creationDate = message.getCreationDate();
		String msgBody = message.getBody();
		
		buf.append("<table bgcolor=\"#cccccc\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"");
		buf.append( 100-(3*indentation) ).append("%\" align=\"right\">");
		buf.append("<td><table bgcolor=\"#cccccc\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"100%\">");
		buf.append("<tr bgcolor=\"#eeeeee\">");
		buf.append("<td width=\"1%\" nowrap>");
		buf.append("<span class=\"messageHeader\">");
		buf.append( subject );
		buf.append("</span>");
		buf.append("<br>");
		buf.append("<span class=\"messageAuthor\">");
		if( msgIsAnonymous ) {
			String displayName = "<i>匿名</i>";
			String savedName = message.getProperty("name");
			String savedEmail = message.getProperty("email");
			if( savedName != null ) {
				displayName = "<i>" + savedName + "</i>";
			}
			if( savedEmail != null ) {
				displayName = "<a href=\"mailto:" + savedEmail + "\">" + displayName + "</a>";
			}
			buf.append(displayName);
		} else {
			
			if( author.isEmailVisible() ) {
				userName = "<a href=\"mailto:" + authorEmail + "\">" + userName + "</a>";
			}
			buf.append("posted by: ").append(userName);
			if( author.isNameVisible() && (authorName!=null && !authorName.equals("")) ) {
				buf.append(" ( ");
				if( author.isEmailVisible() ) {
					buf.append("&nbsp;<i><a href=\"mailto:").append(authorEmail).append("\">");
				}
				buf.append(authorName);
				if( author.isEmailVisible() ) {
					buf.append("</a>");
				}
				buf.append(" )");
			}
		}
		//if( authorEmail != null && !authorEmail.equals("") ) {
		//	buf.append("&nbsp;<i><a href=\"mailto:").append(authorEmail).append("\">").append(authorEmail).append("</a></i>");
		//}
		buf.append("</span>");
		buf.append("</td>");
		buf.append("<td width=\"98%\" align=\"center\">");
		buf.append("<a href=\"post.jsp?reply=true&forum=");
		buf.append(forumID).append("&thread=").append(threadID).append("&message=").append(messageID).append("\"");
		buf.append("><img src=\"images/reply.gif\" width=\"50\" height=\"19\" alt=\"点击这里回应这个消息 \" border=\"0\"></a>");
		buf.append("</td>");
		buf.append("<td width=\"1%\" nowrap align=\"center\">");
		buf.append("<small class=\"date\">Posted ").append(SkinUtils.dateToText(creationDate));
		buf.append("<br><i>").append(dateFormatter.format(creationDate)).append("</i></small>");
		buf.append("</td>");
		buf.append("</tr>");
		buf.append("<tr><td bgcolor=\"#ffffff\" colspan=\"3\">");
		buf.append("<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">");
		buf.append("<td>").append( (msgBody!=null)?msgBody:"" ).append("</td>");
		buf.append("</table>");
		buf.append("</td>");
		buf.append("</tr>");
		buf.append("</table>");
		buf.append("</td>");
		buf.append("</table>");
		buf.append("<br clear=\"all\"><br>\n\n");
		} catch( Exception ignored ) {}
		return buf.toString();
	}
	
	/**
	 * Recursive method to print all the children of a message.
	 */	
	private String printChildren( TreeWalker walker, Forum forum, ForumThread thread, ForumMessage message, int indentation, String mode )
	{
		StringBuffer buf = new StringBuffer();
		
		buf.append( printChildMessage( forum, thread, message, indentation, mode ) );
		
		// recursive call
        int numChildren = walker.getChildCount(message);
        if( numChildren > 0 ) {
            for( int i=0; i<numChildren; i++ ) {
                buf.append(
					printChildren( walker, forum, thread, walker.getChild(message,i), (indentation+1), mode )
				);
            }
        }
		return buf.toString();
    }

  	////////////////////////
	// global page variables
	
	// date formatter for today's date
	private final SimpleDateFormat todayDateFormatter = 
		new SimpleDateFormat("MMMM d");

  	///////////////////////
	// breadcrumb variables
	
	// change these values to customize the look of your breadcrumb bar
	
	// Colors
	final static String crumbBgcolor = "#999999";
	final static String crumbFgcolor = "#ccccdd";

  	/////////////////////
	// toolbar variables
	
	// change these values to customize the look of your toolbar
	
	// Colors
	final static String toolbarBgcolor = "#cccccc";
	final static String toolbarFgcolor = "#eeeeff";

  
  public void
  _jspService(javax.servlet.http.HttpServletRequest request,
              javax.servlet.http.HttpServletResponse response)
    throws java.io.IOException, javax.servlet.ServletException
  {
    com.caucho.jsp.QPageContext pageContext = (com.caucho.jsp.QPageContext) com.caucho.jsp.QJspFactory.create().getPageContext(this, request, response, "/forum/error.jsp", true, 8192, true);
    javax.servlet.jsp.JspWriter out = (javax.servlet.jsp.JspWriter) pageContext.getOut();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    javax.servlet.http.HttpSession session = pageContext.getSession();
    javax.servlet.ServletContext application = pageContext.getServletContext();
    response.setContentType("text/html;charset=gb2312");
    request.setCharacterEncoding("GB2312");
    try {
      pageContext.write(_jsp_string0, 0, _jsp_string0.length);
      
/**
 *	$RCSfile: viewThread.jsp,v $
 *	$Revision: 1.5.2.3 $
 *	$Date: 2001/01/21 21:30:25 $
 */

      pageContext.write(_jsp_string0, 0, _jsp_string0.length);
      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      pageContext.write(_jsp_string2, 0, _jsp_string2.length);
      	////////////////////////
	// 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();
	}

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	///////////////////////
	// page forum variables
	
	// do not delete these
	ForumFactory forumFactory = ForumFactory.getInstance(authToken);
	User user = forumFactory.getProfileManager().getUser(authToken.getUserID());
	long userLastVisitedTime = SkinUtils.getLastVisited(request,response);

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	//////////////////////
	// get parameters
	int forumID  = ParamUtils.getIntParameter(request,"forum",-1);
	int threadID = ParamUtils.getIntParameter(request,"thread",-1);
	String mode = ParamUtils.getParameter(request,"mode");
	if( mode == null ) {
		mode = "threaded";
	}

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	//////////////////////
	// page error variables
	
	String errorMessage = "";
	
	boolean invalidForumID = (forumID < 0);
	boolean invalidThreadID = (threadID < 0);
	boolean notAuthorizedToViewForum = false;
	boolean forumNotFound = false;
	boolean threadNotFound = false;
	boolean rootMessageNotFound = false;

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	//////////////////////////
	// try loading up forums (exceptions may be thrown)
	Forum forum = null;
	try {
		forum = forumFactory.getForum(forumID);
	}
	catch( UnauthorizedException ue ) {
		notAuthorizedToViewForum = true;
	}
	catch( ForumNotFoundException fnfe ) {
		forumNotFound = true;
	}

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	//////////////////////////////////
	// try loading up the thread
	ForumThread thread = null;
	if( forum != null && !invalidThreadID ) {
		try {
			thread = forum.getThread(threadID);
		} catch( ForumThreadNotFoundException ftnfe ) {}
		if( thread == null ) {
			threadNotFound = true;
		}
	}

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	///////////////////////
	// Try loading up the root message
	ForumMessage rootMessage = null;
	int rootMessageID = -1;
	rootMessage = thread.getRootMessage();
	rootMessageID = rootMessage.getID();

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	/////////////////////
	// global error check
	boolean errors = (invalidForumID || invalidThreadID 
		|| notAuthorizedToViewForum || forumNotFound 
		|| threadNotFound || rootMessageNotFound || (forum==null) );

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      	/////////////////////
	// check for errors
	if( errors ) {
		if( invalidForumID ) {
			errorMessage = "您没有指定论坛或者您指定的论坛ID非法  .";
		}
		else if( notAuthorizedToViewForum ) {
			errorMessage = "您没有权利访问这个论坛 .";
		}
		else if( forumNotFound ) {
			errorMessage = "被请求的论坛在系统中不存在.";
		}
		else if( threadNotFound ) {
			errorMessage = "被请求的线索在系统中不存在 .";
		}
		else if( rootMessageNotFound ) {
			errorMessage = "被请求的信息在系统中不存在 .";
		}
		else {
			errorMessage = "发生常规错误 .请联系   "
				+ "管理员求助 .";

⌨️ 快捷键说明

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