Tải bản đầy đủ (.pdf) (50 trang)

Tài liệu XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P14 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (165.44 KB, 50 trang )

632
Appendix C Source Code for bonForum Web Application
Other bonForum sites can be listed here too!
</p>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<%—
Here we list links as created by the XSLT
Output can create a table, a list, or whatever is possible!
—%>
<p>
<bon:transform type=”xalanVersion”
inXML=
“bonForumXML”
inXSL=
“..\\webapps\\bonForum\\mldocs\\bonForumLinks.xsl”
outDoc=
“output”>
<%=output%>
</bon:transform>
</p>
<%—
Note that we here use actorStatus, actionStatus and
thingStatus instead of bonCommand to control the next
state of the web application. That is just to test this
alternate destination control mechanism.
—%>
<p>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”hidden” name=”actorStatus”


value=”visitor”></input>
<input type=”hidden” name=”actionStatus”
value=”executes”></input>
<input type=”hidden” name=”thingStatus”
value=”choice”></input>
<input type=”submit” value=”Back to last bonForum!”
name=”submit”></input>
</p>
</form>
<table border=”0” rows=”1” width=”100%”>
<tr>
<td align=”center”>
<a href=”/bonForum/jsp/forum/license.jsp”>
<img border=”0” src=”/bonForum/images/bonForumLogo.gif”
alt=”BonForum open source license” width=”50” height=”50”>
</a>
</td>
</tr>
</table>
<font face=”Arial” color=”blue”>
<bon:outputDebugInfo/>
</font>
15 1089-9 XC 6/26/01 7:40 AM Page 632
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
633
C.31 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\forum_entry.jsp
<h5>
</font>
<%@ include file=”../../mldocs/bonForumBottom.html” %>
</body>

</html>
C.31 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\forum_entry.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page import=”java.io.*” %>
<%@ page errorPage=”forum_error.jsp” %>
<%
String actorNickname = “”;
try {
actorNickname =
(String)session.getAttribute(“actorNickname”);
if(actorNickname == null) {
actorNickname = “”;
}
}
catch(java.lang.NullPointerException ex) {
actorNickname = “”;
}
%>
<%
String actorNicknameNotAvailable = “”;
try {
actorNicknameNotAvailable =
(String)session.getAttribute(“actorNicknameNotAvailable”);
if(!actorNicknameNotAvailable.equals(“”)) {
actorNicknameNotAvailable =
“Please try another nickname. “ +
actorNicknameNotAvailable +

“ is not available! “ ;
}
if(actorNicknameNotAvailable == null) {
actorNicknameNotAvailable = “”;
}
}
catch(java.lang.NullPointerException ex) {
actorNicknameNotAvailable = “”;
}
%>
<html>
<head>
<meta http-equiv=”Content-Type”
15 1089-9 XC 6/26/01 7:40 AM Page 633
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
634
Appendix C Source Code for bonForum Web Application
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana” color=”black”>
<a name=”entry”> </a>
<h5>
<form name=”forum_entry” method=”POST”
action=”/bonForum/servlet/BonForumEngine”>

<table border=0 cellspacing=0 cellpadding=0
rows=4 cols=1 width=100% bgcolor=#00FFFF>
<tr>
<label for=”actorNickname”>Nickname: </label>
<input type=”text” name=”actorNickname”
value=<%=actorNickname%> ></input>
</tr>
<tr>
<label for=”actorAge”>Your age: </label>
<input type=”text” name=”actorAge”></input>
</tr>
<%—
<tr>
<label for=”actorAgeGroup”>How old are you?
&nbsp;&nbsp;&nbsp;</label>
<input type=”radio” name=”actorAgeGroup”
value=”0-12”>0 to 12&nbsp;&nbsp;&nbsp;</input>
<input type=”radio” name=”actorAgeGroup”
value=”13-17”>13 to 17&nbsp;&nbsp;&nbsp;</input>
<input type=”radio” name=”actorAgeGroup”
value=”18-129+”>21 to 129</input>
</tr>
—%>
<tr>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”hidden” name=”bonCommand”
value=”visitor_executes_choice”></input>
<input type=”submit” value=”continue” name=”submit”></input>
</tr>

<tr>
<font color=”red”>
<%= actorNicknameNotAvailable %>
</font>
</tr>
</table>
</form>
<font face=”Arial” color=”blue”>
15 1089-9 XC 6/26/01 7:40 AM Page 634
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
635
C.32 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\forum_error.jsp
<bon:outputDebugInfo/>
</font>
</h5>
</font>
<%@ include file=”../../mldocs/bonForumSplash.html” %>
</body>
</html>
C.32 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\forum_error.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page isErrorPage=”true” %>
<%@ page import=”javax.servlet.http.*” %>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;

charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”lime”>
<h3> Error! Please enter bonForum again!
</h3>
<h2>
<%
String errorMessage1 = “Error1”;
String errorMessage2 = “Error2”;
try {
%>
<jsp:useBean id=”bonForumUtils”
class=”de.tarent.forum.BonForumUtils”
scope=”application”/>
<p>
Message: <%=bonForumUtils.normalize(exception.getMessage())%>
</p>
<%
}
catch(java.lang.NullPointerException ex) {
String requestedSessionId = request.getRequestedSessionId();
if(request.isRequestedSessionIdValid()) {
errorMessage1 = requestedSessionId + “ is valid session.”;
}
else {
15 1089-9 XC 6/26/01 7:40 AM Page 635

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
636
Appendix C Source Code for bonForum Web Application
errorMessage1 = requestedSessionId + “ is NOT valid
session.”;
}
HttpSession maybeSession = request.getSession(false);
if(maybeSession == null) {
errorMessage2 = “Session is null.”;
}
else {
errorMessage2 = “Session not null.”;
}
%>
<%= errorMessage1 %><BR>
<%= errorMessage2 %>
<%
}
%>
</h2>
<h3>
Try re-entering bonForum. If the error
keeps happening, you can copy this browser page
and visit the BonForum Project
website on SourceForge:
<a href=””>
www.bonforum.org
</a>. Check the bug tracker there. You may find
some info there, or if this problem is a new one,
you can report it there, and paste this page into

your bug report!
</h3>
<h2>
<a href=”UserMustLogin.tfe”>
bonForum re-login
</a>
</h2>
<form name=”forum_error” method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<input type=”hidden” name=”actorReturning”
value=”no”></input>
<input type=”hidden” name=”bonCommand”
value=”forum_error”></input>
<p>
<input type=”submit” value=”bonForum re-entry”
name=”submit”></input>
</p>
<label for=”debug”>debug</label>
<input type=”checkbox” id=”debug”
name=”output_debug_info” value=”yes”></input>
</form>
<%
try {
exception.printStackTrace();
15 1089-9 XC 6/26/01 7:40 AM Page 636
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
637
C.33 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\forum_error_robot.jsp
}
catch(Throwable ex) {

}
%>
<font face=”Arial” color=”black”>
<bon:outputDebugInfo force=”yes”/>
</font>
</body>
</html>
C.33 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\forum_error_robot.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<%
String target = (String)session.getAttribute(“target”);
String document = (String)session.getAttribute(“document”);
String refresh = (String)session.getAttribute(“refresh”);
String increment = (String)session.getAttribute(“increment”);
String limit = (String)session.getAttribute(“limit”);

String message = (String)session.getAttribute(“message”);
%>
<%— using message “debug” shows some info —%>
<jsp:plugin type=”applet” code=”BonForumRobot.class”
codebase=”/bonForum/jsp/forum/applet”
jreversion=”1.3.0” width=”0” height=”0” >
<jsp:params>
<jsp:param name=”target” value=”<%=target%>”/>
<jsp:param name=”document” value=”<%=document%>”/>
<jsp:param name=”refresh” value=”<%=refresh%>”/>
<jsp:param name=”increment” value=”<%=increment%>”/>
<jsp:param name=”limit” value=”<%=limit%>”/>
<jsp:param name=”message” value=”<%=message%>”/>
</jsp:params>
<jsp:fallback>Plugin tag OBJECT or EMBED
15 1089-9 XC 6/26/01 7:40 AM Page 637
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
638
Appendix C Source Code for bonForum Web Application
not supported by browser.
</jsp:fallback>
</jsp:plugin>
</body>
</html>
C.33 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\forum_login.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ page import=”java.io.*” %>
<%@ taglib uri=”
prefix=”bon” %>

<%@ page errorPage=”forum_error.jsp” %>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana”>
<a name=”entry”> </a>
<table border=”0” rows=”3” width=”100%”>
<tr>
<td align=”center”>
<a href=”/bonForum/jsp/forum/license.jsp”>
<img border=”0” src=”/bonForum/images/bonForumLogo.gif”
alt=”View BonForum License”>
</a>
</td>
</tr>
<tr>
<td align=”center”>
<form name=”forum_login_enter” method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<table border=0 cellspacing=0 cellpadding=0
rows=3 cols=1 width=100% bgcolor=#00FFFF>
<tr>

<td align=”center”>
<input type=”hidden” name=”actorReturning”
value=”no”></input>
<input type=”hidden” name=”bonCommand”
value=”forum_entry”></input>
<input type=”submit” value=”Enter bonForum”
15 1089-9 XC 6/26/01 7:40 AM Page 638
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
639
C.33 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\forum_login.jsp
name=”submit”></input>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td align=”left”>
<form name=”forum_login_system” method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<table rows=1 cols=1 width=100% bgcolor=#00FFFF>
<tr>
<td align=”center”>
<input type=”hidden” name=”actorReturning”
value=”no”></input>
<input type=”hidden” name=”bonCommand”
value=”system_executes_command”></input>
<p>
<input type=”submit” value=”System Commands”

name=”submit”></input></p>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<font face=”Arial” color=”blue”>
<bon:outputDebugInfo/>
<%—
<bon:outputDebugInfo force=”yes”/>
—%>
<font>
</font>
<%@ include file=”../../mldocs/bonForumSplash.html” %>
</body>
</html>
C.34 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\forum_login_robot.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
15 1089-9 XC 6/26/01 7:40 AM Page 639
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
640
Appendix C Source Code for bonForum Web Application
<%@ page errorPage=”forum_error.jsp” %>
<html>
<head>

<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<%
String target = (String)session.getAttribute(“target”);
String document = (String)session.getAttribute(“document”);
String refresh = (String)session.getAttribute(“refresh”);
String increment = (String)session.getAttribute(“increment”);
String limit = (String)session.getAttribute(“limit”);
String message = (String)session.getAttribute(“message”);
%>
<%— using message “debug” shows some info —%>
<jsp:plugin type=”applet” code=”BonForumRobot.class”
codebase=”/bonForum/jsp/forum/applet”
jreversion=”1.3.0” width=”0” height=”0” >
<jsp:params>
<jsp:param name=”target” value=”<%=target%>”/>
<jsp:param name=”document” value=”<%=document%>”/>
<jsp:param name=”refresh” value=”<%=refresh%>”/>
<jsp:param name=”increment” value=”<%=increment%>”/>
<jsp:param name=”limit” value=”<%=limit%>”/>
<jsp:param name=”message” value=”<%=message%>”/>
</jsp:params>
<jsp:fallback>Plugin tag OBJECT or EMBED

not supported by browser.
</jsp:fallback>
</jsp:plugin>
</body>
</html>
C.35 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\quest_executes_chat.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
15 1089-9 XC 6/26/01 7:40 AM Page 640
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
641
C.36 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_chat_console.jsp
<%@ page errorPage=”forum_error.jsp” %>
<%
session.setAttribute(“target”, “display”);
session.setAttribute(“document”, request.getScheme() + “://” +
request.getServerName() + “:” +
request.getServerPort() +
“/bonForum/jsp/forum/guest_executes_chat_frame.jsp”);
session.setAttribute(“refresh”, “true”);
session.setAttribute(“increment”, “5000”);
session.setAttribute(“limit”, “5000”);
session.setAttribute(“message”, “refreshing...”);
%>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;

charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<noframes>/bonForum/noframe/html.index</noframes>
<frameset rows=”55%, 45%”>
<frame src=”/bonForum/jsp/forum/guest_executes_chat_frame.jsp.tfe”
name=”display”/>
<frameset cols=”77%, 23%”>
<frame src=”/bonForum/jsp/forum/guest_executes_chat_controls.jsp.tfe”
name=”controls”/>
<frame src=”/bonForum/jsp/forum/guest_executes_chat_robot.jsp.tfe”
name=”robot”/>
</frameset>
</frameset>
</html>
C.36 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_chat_
console.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>

15 1089-9 XC 6/26/01 7:40 AM Page 641
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
642
Appendix C Source Code for bonForum Web Application
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<%— go via robot to leave frameset —%>
<%
request.setAttribute(“target”, “_top”);
request.setAttribute(“document”, request.getScheme() + “://” +
request.getServerName() + “:” +
request.getServerPort() +
“/bonForum/jsp/forum/guest_executes_command.jsp”);
request.setAttribute(“refresh”, “true”);
request.setAttribute(“increment”, “100”);
request.setAttribute(“limit”, “1”);
request.setAttribute(“message”, “guest command console loading!”);
%>
<jsp:forward page=”actor_leaves_frameset_robot.jsp.tfe”/>
</font>
</body>
</html>
C.37 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_chat_
controls.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>

<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<%— greet guest by nickname: —%>
<%
String actorNickname =
((String)session.getAttribute(“actorNickname”));
if(actorNickname == null ||
actorNickname.trim().length() < 1) {
actorNickname = “&lt;unknown visitor&gt;”;
}
String chatWelcomeMessage = “” +
actorNickname + “! Please make a choice:”;
%>
<%—
Here we indicate to user if first or latest
messages will be displayed. Note that previous
and next are one-shot actions so are left alone
—%>
15 1089-9 XC 6/26/01 7:40 AM Page 642
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
643
C.37 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_chat_controls.jsp
<%
String chatNavigatorFirst = “first”;
String chatNavigatorPrevious = “previous”;
String chatNavigatorNext = “next”;
String chatNavigatorLast = “latest”;
String chatMessagesNavigator = “”;
try {

chatMessagesNavigator =
(String)session.getAttribute(“chatMessagesNavigator”);
if(!(chatMessagesNavigator.equals(“first”)) &&
!(chatMessagesNavigator.equals(“previous”)) &&
!(chatMessagesNavigator.equals(“next”))) {
chatMessagesNavigator = “last”;
}
if(chatMessagesNavigator.equals(“first”)) {
chatNavigatorFirst = “FIRST”;
}
else if(chatMessagesNavigator.equals(“previous”)) {
chatNavigatorPrevious = “previous”;
}
else if(chatMessagesNavigator.equals(“next”)) {
chatNavigatorNext = “next”;
}
else {
chatNavigatorLast = “LATEST”;
}
}
catch (Exception ee) {
chatMessagesNavigator = “last”;
}
%>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>

<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana”>
<a name=”entry”></a>
<h5>
<table border=0 cellspacing=0 cellpadding=0
rows=4 cols=1 width=100% bgcolor=#00FFFF>
<tr>
<%= chatWelcomeMessage %>
</tr>
<form method=”POST” action=”/bonForum/servlet/BonForumEngine”>
15 1089-9 XC 6/26/01 7:40 AM Page 643
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
644
Appendix C Source Code for bonForum Web Application
<tr width=100%>
<table border=0 cellspacing=0 cellpadding=0
rows=1 cols=1 width=100% bgcolor=#00FFFF>
<tr>
<label for=”chatMessage”>chat message</label>
<font face=”Arial Narrow”>
<input type=”text” name=”chatMessage” size=50></input>
</font>
</tr>
</table>
</tr>
<tr width=100%>

<table border=0 cellspacing=0 cellpadding=0
rows=4 cols=1 width=100% bgcolor=#00FFFF>
<tr>
<label for=”bonCommand”>send this message</label>
<input type=”radio” name=”bonCommand”
value=”guest_executes_chat_controls”
CHECKED></input>
</tr>
<tr>
<label for=”bonCommand”>exit this chat</label>
<input type=”radio” name=”bonCommand”
value=”guest_executes_chat_ready”></input>
</tr>
<tr>
<label for=”bonCommand”>execute guest command</label>
<input type=”radio” name=”bonCommand”
value=”guest_executes_chat_console”></input>
</tr>
<tr>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”submit” value=”Do it!”
name=”submit”></input>
</tr>
</table>
</tr>
</form>
<tr width=10%>
<table border=0 cellspacing=0 cellpadding=0
rows=1 cols=4 width=10% bgcolor=#00FFFF>

<%— here we display navigator buttons to
page through chat messages —%>
<label for=”chatMessagesNavigator”>page messages</label>
<td width=10%>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<input type=”hidden” name=”chatMessagesNavigator”
value=”first”></input>
<input type=”hidden” name=”actorReturning”
15 1089-9 XC 6/26/01 7:40 AM Page 644
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
645
C.37 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_chat_controls.jsp
value=”yes”></input>
<input type=”hidden” name=”bonCommand”
value=”guest_executes_chat_controls”></input>
<input type=”submit” value=<%=chatNavigatorFirst%>
name=”submit”></input>
</form>
</td>
<td width=10%>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<input type=”hidden” name=”chatMessagesNavigator”
value=”previous”></input>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”hidden” name=”bonCommand”
value=”guest_executes_chat_controls”></input>
<input type=”submit”

value=<%=chatNavigatorPrevious%>
name=”submit”></input>
</form>
</td>
<td width=10%>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<input type=”hidden” name=”chatMessagesNavigator”
value=”next”></input>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”hidden” name=”bonCommand”
value=”guest_executes_chat_controls”></input>
<input type=”submit”
value=<%=chatNavigatorNext%>
name=”submit”></input>
</form>
</td>
<td width=10%>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<input type=”hidden” name=”chatMessagesNavigator”
value=”last”></input>
<input type=”hidden” name=”actorReturning”
value=”yes”></input>
<input type=”hidden” name=”bonCommand”
value=”guest_executes_chat_controls”></input>
<input type=”submit”
value=<%=chatNavigatorLast%> name=”submit”></input>
</form>

</td>
</table>
</tr>
</table>
15 1089-9 XC 6/26/01 7:40 AM Page 645
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
646
Appendix C Source Code for bonForum Web Application
<font face=”Arial” color=”blue”>
<bon:outputDebugInfo/>
</font>
</h5>
</font>
<%@ include file=”../../mldocs/bonForumBottom.html” %>
</body>
</html>
C.38 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_chat_
frame.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<%— here we get the chat subject and
topic settings for later display —%>
<%
String chatSubject = (String)session.getAttribute(“chatSubject”);
String chatSubjectMessage = “”;
if(chatSubject != null && chatSubject.trim().length() > 0) {
chatSubjectMessage = “category: “ + chatSubject;

}
String chatTopic = (String)session.getAttribute(“chatTopic”);
String chatTopicMessage = “”;
if(chatTopic != null && chatTopic.trim().length() > 0) {
chatTopicMessage = “topic: “ + chatTopic;
}
%>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana”>
<a name=”entry”></a>
<h5>
<table border=0 cellspacing=0 cellpadding=0
rows=4 cols=1 width=100% bgcolor=#00FFFF>
<tr>
15 1089-9 XC 6/26/01 7:40 AM Page 646
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
647
C.38 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_chat_frame.jsp
<%=chatSubjectMessage%>
</tr>

<tr>
<%=chatTopicMessage%>
</tr>
<%— here we get the number of lines per page
for the chat messages display —%>
<%
String chatMessagesPageSize =
(String)session.getAttribute(“chatMessagesPageSize”);
int size = 10;
try {
size = Integer.parseInt(chatMessagesPageSize);
}
catch (NumberFormatException nFE) {
chatMessagesPageSize = “10”;
}
if(size > 99) {
chatMessagesPageSize = “99”;
}
else if(size < 1) {
chatMessagesPageSize = “1”;
}
session.setAttribute(“chatMessagesPageSize”,
chatMessagesPageSize);
%>
<%— Here we list the messages in this chat —%>
<tr>
<form method=”POST”
action=”/bonForum/servlet/BonForumEngine”>
<select size=”<%= chatMessagesPageSize %>”
name=”chatMessages”>

<font face=”Arial Narrow”>
<bon:outputChatMessages command=”bonForumXML”>
<option><%= output %></option>
</bon:outputChatMessages>
</font>
</select>
</form>
</tr>
<%— here we get the page number and
number of pages for later display —%>
<%
(String)session.getAttribute(“chatPageNumber”);
String chatNumberOfPages =
(String)session.getAttribute(“chatNumberOfPages”);
%>
<tr>
page:&nbsp;<%= chatPageNumber %>
&nbsp;of&nbsp;<%= chatNumberOfPages %>
</tr>
15 1089-9 XC 6/26/01 7:40 AM Page 647
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
648
Appendix C Source Code for bonForum Web Application
</table>
<%— for debugging, we can display variables —%>
<%— chatMessagesPageSize:<%= chatMessagesPageSize %>
size:<%= size %>
—%>
<font face=”Arial” color=”blue”>
<bon:outputDebugInfo/>

</font>
</h5>
</font>
</body>
</html>
C.39 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_chat_
ready.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<%— go via robot to leave frameset —%>
<%
request.setAttribute(“target”, “_top”);
request.setAttribute(“document”,
request.getScheme() + “://” +
request.getServerName() + “:” +
request.getServerPort() +

“/bonForum/jsp/forum/guest_exits_chat.jsp”);
request.setAttribute(“refresh”, “true”);
request.setAttribute(“increment”, “100”);
request.setAttribute(“limit”, “1”);
request.setAttribute(“message”, “guest exiting chat!”);
%>
<jsp:forward page=”actor_leaves_frameset_robot.jsp.tfe”/>
</body>
</html>
15 1089-9 XC 6/26/01 7:40 AM Page 648
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
649
C.40 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_chat_robot.jsp
C.40 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_chat_
robot.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<%
String target = (String)session.getAttribute(“target”);
String document = (String)session.getAttribute(“document”);
String refresh = (String)session.getAttribute(“refresh”);
String increment = (String)session.getAttribute(“increment”);
String limit = (String)session.getAttribute(“limit”);
String message = (String)session.getAttribute(“message”);
%>
<%— message “debug” shows some info —%>
<html>

<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana”>
<table>
<tr>
<img border=”0” src=”/bonForum/images/bonForumLogo.gif”
alt=”bonForum” width=”112” height=”112”>
</tr>
<tr>
<jsp:plugin type=”applet” code=”BonForumRobot.class”
codebase=”/bonForum/jsp/forum/applet”
jreversion=”1.3.0” width=”400” height=”160” >
<jsp:params>
<jsp:param name=”target” value=”<%=target%>”/>
<jsp:param name=”document” value=”<%=document%>”/>
<jsp:param name=”refresh” value=”<%=refresh%>”/>
<jsp:param name=”increment” value=”<%=increment%>”/>
<jsp:param name=”limit” value=”<%=limit%>”/>
<jsp:param name=”message” value=”<%=message%>”/>
</jsp:params>
<jsp:fallback>Plugin tag OBJECT or EMBED
not supported by browser.

</jsp:fallback>
</jsp:plugin>
15 1089-9 XC 6/26/01 7:40 AM Page 649
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
650
Appendix C Source Code for bonForum Web Application
</tr>
</table>
<font face=”Arial” color=”blue”>
<bon:outputDebugInfo/>
</font>
</font>
</body>
</html>
C.41 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_
command.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<%
session.setAttribute(“target”, “display”);
session.setAttribute(“document”, request.getScheme() + “://” +
request.getServerName() + “:” +
request.getServerPort() +
“/bonForum/jsp/forum/guest_executes_command_frame.jsp”);
session.setAttribute(“refresh”, “false”);
session.setAttribute(“increment”, “15000”);
session.setAttribute(“limit”, “5000”);

session.setAttribute(“message”, “hello”);
%>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>
</meta>
<title>
bonForum
</title>
</head>
<noframes>/bonForum/noframe/html.index</noframes>
<frameset rows=”59%, 41%”>
<frame src=”/bonForum/jsp/forum/guest_executes_command_frame.jsp.tfe”
name=”display”/>
<frameset cols=”77%, 23%”>
<frame src=”/bonForum/jsp/forum/guest_executes_command_controls.jsp.tfe”
name=”controls”/>
<frame src=”/bonForum/jsp/forum/guest_executes_command_robot.jsp.tfe”
name=”robot”/>
</frameset>
15 1089-9 XC 6/26/01 7:40 AM Page 650
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
651
C.42 Filename: TOMCAT_HOME\webapps\bonForum\jsp\forum\guest_executes_command_controls.jsp
</frameset>
</html>
C.42 Filename: TOMCAT_HOME\webapps\
bonForum\jsp\forum\guest_executes_

command_controls.jsp
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<%@ taglib uri=”
prefix=”bon” %>
<%@ page errorPage=”forum_error.jsp” %>
<%— here we get the number of lines per page
for the chat messages display —%>
<%
String chatMessagesPageSize =
(String)session.getAttribute(“chatMessagesPageSize”);
int size = 10;
try {
size = Integer.parseInt(chatMessagesPageSize);
}
catch (NumberFormatException nFE) {
chatMessagesPageSize = “10”;
}
if(size > 99) {
chatMessagesPageSize = “99”;
}
else if(size < 1) {
chatMessagesPageSize = “1”;
}
session.setAttribute(“chatMessagesPageSize”, chatMessagesPageSize);
%>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html;
charset=x-user-defined”>

</meta>
<title>
bonForum
</title>
</head>
<body bgcolor=”#00FFFF”>
<font face=”Verdana”>
<a name=”entry”></a>
<h5>
<%— later, add commands and options for guests here! —%>
<table border=0 cellspacing=0 cellpadding=0
rows=2 cols=1 width=100% bgcolor=#00FFFF>
15 1089-9 XC 6/26/01 7:40 AM Page 651
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

×