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

📄 post.jsp

📁 jive3论坛开源 最新 有版主功能 jive3论坛开源 最新 有版主功能 jive3论坛开源 最新 有版主功能
💻 JSP
字号:
<%/** *	$RCSfile: post.jsp,v $ *	$Revision: 1.3 $ *	$Date: 2002/10/26 20:48:10 $ */%><%@ page import="java.net.*,                 java.text.*,                 java.util.*,                 com.jivesoftware.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*"    errorPage="error.jsp"%><%@ include file="global.jsp" %><%  // Login code. Usually the following code (below the parameter code) is in    // global.jsp, but on this page we're not including global.jsp so we can    // have better control over the way UnauthorizedExceptions are handled.    // First, get the message parameters because we might be entering this page    // after submitting the message form to post a message.    long forumID = ParamUtils.getLongParameter(request,"forum",-1L);	long threadID = ParamUtils.getLongParameter(request,"thread",-1L);    long messageID = ParamUtils.getLongParameter(request,"message",-1L);    String subject = ParamUtils.getParameter(request,"subject");    String body = ParamUtils.getParameter(request,"body");    String name = ParamUtils.getParameter(request,"name");    String email = ParamUtils.getParameter(request,"email");    boolean doPost = ParamUtils.getBooleanParameter(request,"doPost");    boolean reply = ParamUtils.getBooleanParameter(request,"reply");    boolean cancel = request.getParameter("cancel") != null;    boolean errors = false;    // Check for a cancel:    if (cancel) {        // Redirect back to the forum page        response.sendRedirect("forum.jsp?forum=" + forumID);        return;    }    // Load the forum we're interested in:    Forum forum = forumFactory.getForum(forumID);    // The thread we're posting in (if this is a reply).	ForumThread thread = null;    // The parent message we're replying to (if this is a reply).	ForumMessage parentMessage = null;	if (reply) {     	thread = forum.getThread(threadID);        // A message ID might not be passed in. If this is the case, we're        // replying to the root message so get the message ID from the root        // message of the thread.        if (messageID == -1L) {            parentMessage = thread.getRootMessage();            messageID = parentMessage.getID();        }        else {            parentMessage = thread.getMessage(messageID);        }	}    // A user manager lets us get and set user information:    UserManager userManager = forumFactory.getUserManager();    // Validate the new message fields:    if (subject == null || body == null) {        errors = true;    }    // Post the message.    if (doPost && !errors) {        // Validate the incoming fields:        if (subject == null || body == null) {            errors = true;        }        // The new message object        ForumMessage newMessage = null;        // Create the new message object        if (pageUser == null) {            newMessage = forum.createMessage();        } else {            newMessage = forum.createMessage(pageUser);        }        newMessage.setSubject(subject);        newMessage.setBody(body);        // set message properties if this is a guest posting        if (pageUser == null) {            if (name != null) { newMessage.setProperty("name", name); }            if (email != null) { newMessage.setProperty("email", email); }        }        // if this is a reply, add it to the thread        if (reply) {            thread.addMessage(parentMessage,newMessage);        }        else {            // it is a new posting            thread = forum.createThread(newMessage);            forum.addThread(thread);            // Note: We have to reset the message to be the root message of the            // thread. This call is made in order to get a message object with            // the correct permissions.            newMessage = thread.getRootMessage();        }        // Re-get the thread object        thread = newMessage.getForumThread();		// Now that posting is done, redirect to the new message:        response.sendRedirect(            "thread.jsp?forum=" + forumID + "&thread=" + thread.getID()                + "&message=" + newMessage.getID() + "#" + newMessage.getID()        );        return;    }%><%@ include file="header.html" %><jsp:include page="breadcrumbs.jsp" flush="true">    <jsp:param name="forum" value="<%= String.valueOf(forum.getID()) %>" /></jsp:include><p><%  if (reply) { %>    Post a Reply to: <%= parentMessage.getSubject() %><%  } else { %>    Post a New Topic<%  } %></p><form action="post.jsp" method="post" name="postForm"><input type="hidden" name="doPost" value="true"><input type="hidden" name="reply" value="<%= reply %>"><input type="hidden" name="forum" value="<%= forumID %>"><input type="hidden" name="thread" value="<%= threadID %>"><input type="hidden" name="message" value="<%= messageID %>"><%	// Add an "Re: " to the subject if this is a reply    if (reply) {        subject = parentMessage.getSubject();        if (!subject.startsWith("Re: ")) {            subject = "Re: " + subject;        }    }    // Escape any quotes in the subject.    if (subject != null) {        subject = StringUtils.replace(subject, "\"", "&quot;");    }%><table cellpadding="4" cellspacing="0" border="0"><%  if (isGuest) { %>    <tr>        <td align="right">            Name:        </td>        <td>            <input type="text" name="name" value="<%= ((name!=null)?name:"") %>" size="30" maxlength="75">        </td>    </tr>    <tr>        <td align="right">            Email:        </td>        <td>            <input type="text" name="email" value="<%= ((email!=null)?email:"") %>" size="30" maxlength="75">        </td>    </tr><%  } %><tr>	<td align="right">        Subject:    </td>	<td>        <input type="text" name="subject" value="<%= ((subject!=null)?subject:"") %>" size="40" maxlength="75">    </td></tr><tr>	<td valign="top" align="right">        <%	if (reply) { %>            Your Reply:        <%	} else { %>            Message:        <%	} %>	</td>	<td>        <textarea name="body" wrap="virtual" cols="58" rows="12"><%= ((body!=null)?body:"") %></textarea>	</td></tr><tr>	<td>&nbsp;</td>	<td>        <input type="submit" value="Post Message">        &nbsp;&nbsp;        <input type="submit" value="Cancel" name="cancel">	</td></tr></table></form><br><%@ include file="footer.html" %>

⌨️ 快捷键说明

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