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

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

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonforum.org”> 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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=”http://www.bonForum.org/taglib/bonForum-taglib” 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. [...]... 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... (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”))... code=”BonForumRobot.class” codebase=”/bonForum/jsp/forum/applet” jreversion=”1.3.0” width=”400” height=”160” > ... for=”bonCommand”>send this message exit this chat execute guest command ... “ + chatTopic; } %> content=”text/html; action=”/bonForum/servlet/BonForumEngine”> increment rating of guest decrement rating of guest exit... CHECKED> exit this chat execute host command ... value=””/> Plugin tag OBJECT or EMBED not supported by browser C.46 Filename: TOMCAT_HOME\webapps\ bonForum\jsp\forum\guest_exits_chat.jsp... chatNavigatorFirst = “first”; String chatNavigatorPrevious = “previous”; String chatNavigatorNext = “next”; String chatNavigatorLast = “latest”; String chatMessagesNavigator = “”; try { chatMessagesNavigator = Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 15 1089-9 XC 6/26/01 7:40 AM Page 660 660 Appendix C Source Code for bonForum Web Application (String)session.getAttribute(... 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); %> . (String)session.getAttribute(“actorNicknameNotAvailable”); if(!actorNicknameNotAvailable.equals(“”)) { actorNicknameNotAvailable = “Please try another nickname. “ + actorNicknameNotAvailable +. not available! “ ; } if(actorNicknameNotAvailable == null) { actorNicknameNotAvailable = “”; } } catch(java.lang.NullPointerException ex) { actorNicknameNotAvailable

Ngày đăng: 24/12/2013, 07:17

Tài liệu cùng người dùng

Tài liệu liên quan