The doInitBody Method 1
The doInitBody method of the outputChatMessages tag handler is very similar to that of the outputPathNames tag handler, which we discussed in Section 10.4.5, The doInitBody Method. One major difference is that the BonForumStore method that is invoked by outputChatMessages is different, as shown here outputTable new TreeMap bonForumStore.outputForumChatMessages command, attrl, attr2, attr3, pageContext.getSession This method returns a TreeMap object with nodeKey.aKey values as keys and chat...
deleteNode
You have seen how the optionally recursive node deletion works. Now let's look at the public method by which a user application deletes a BonNode from a ForestHashtable. Here is the source code for its deleteNode method public boolean deleteNode NodeKey keyOfNodeToDelete, boolean leafOnly if this.containsKey keyOfNodeToDelete if leafOnly return false was not a leaf node, so not deleted return You can see how easy node access is when you have the NodeKey. Of course, this does not require the...
Using Beanshell with Xalan
We had a lot of fun using the Beanshell to learn about Xalan. In Chapter 2, An Environment for Java Software Development, we mentioned the Beanshell as a plugin for the ElixirIDE, called bsh.jar. Look in the ElixirIDE documentation for instructions on installing the plug-in.You will then have a tabbed panel in ElixirIDE with a Beanshell console where you can interactively execute Java statements. That is how we use Beanshell, but you can also obtain, for free, a stand-alone version. Whether you...
Application
C.1 Filename TOMCAT_HOME webapps bonForum WEB-INF web.xml lt xml version H1.0 encoding ISO-8859-1 gt lt DOCTYPE web-app PUBLIC - Sun Microsystems, Inc. DTD Web Application 2.2 EN lt web-app gt bonForum lt display-name gt lt context-param gt lt param-name gt Webmaster lt param-name gt lt param-value gt email bonforum.org lt param-value gt lt context-param gt lt Logging output can be none, all, std, file gt lt context-param gt lt param-name gt Logging lt param-name gt lt param-value gt lt...
Web Application Context for this Servlet
Although Tomcat is a complete HTTP server, its specialty is handling Java servlets and JavaServer Pages JSP .The Tomcat configuration file web.xml determines what Tomcat does with the various requests that it gets, whether directly from a browser or from another server such as Apache.The following document type links the web.xml configuration file to a definition of what a Web application should look like lt DOCTYPE web-app PUBLIC - Sun Microsystems, Inc. DTD Web Application 2.2 EN According to...
The XalanTransformer Class
The following listing comes of the source code for the Xalan1Transformer class, which encapsulates the steps necessary to carry out an XSLT process using the Xalan-Java 1 processor from the Apache XML project. package de.tarent.forum import org.xml.sax. import org.apache.xerces.dom. import org.apache.xerces.parsers. import org.apache.xalan.xslt. XSLT processing using Xalan-Java 1. XSLT of inXML to outDoc using inXSL public String transform String inXML, String inXSL, String outDoc, String...
The service Method An Overall View
First and foremost, the BonForumEngine is a descendant of HTTPServlet.The direct benefit that you get from that includes many things that were already taken care of for you as a developer You simply do not have to solve some hard problems in the area of communication across the world.The best place to start examining the doings of this HTTPServlet is right at its heart the service method. Servicing HttpServletRequest Objects As you know already or could guess by looking at its arguments' types...
The XalanTransformer Class 1
The Xalan2Transformer class was designed to encapsulate XSLT using the Xalan-Java 2 processor from the Apache XML project. In terms of what we have done, as opposed to what was done by that project, there is very little different between this class and the XalanlTransformer class that was just described. By combining the previous discussion with the appropriate documentation from the Xalan-Java 2 release, it should be quite easy to follow the listing of the source code for our class package...
Xalan JAR File
Do not put the Xalan 1.2.2 JAR files in the ext folder for the JDK runtime environment. If you do put it there, you will not have any problems using the Xalan parser in some situations, such as from the command line. However, when it comes time to use it from a JSP, as we do several places in our Web application project for the book, you will get an HTTP 500 internal servlet error. If you are using Xalan 1.2.2 with Tomcat 3.2, the easiest way to get access to Xerces from your Tomcat Web...
The ServletConfig and ServletContext Classes
When a servlet container initializes a servlet instance, it provides it a ServletConfig object.That object encapsulates initialization parameters, which can be used, for example, to tailor the behavior of a servlet to the particular operating system environment that it executes in.The ServletConfig object also contains another important object for the servlet, which is an instance of the ServletContext class. The ServletContext object provides a servlet a way to share objects and communicate...
Tomcat Web App Configuration Files
Every Web application installed in Tomcat has a configuration file, which contains its deployment descriptor. For an example, use Internet Explorer to examine the one for the Examples Web app, which is the file TOMCAT_HOME webapps examples Web-inf web.xml. To understand this configuration file, you can use a text editor to read the file c jakarta-tomcat conf web.dtd, which is the DOCTYPE for a Web application. A detailed discussion of everything in this file is beyond the scope of this book....
C Filename TOMCATHOMEwebapps bonForumdocsbonForumLinksxsl
lt xml version 1.0 gt lt xsl stylesheet version 1.0 gt lt xsl output method xml omit-xml-declaration yes indent no gt lt xsl param name param1 lt xsl template match gt lt table width 100 name bonForums gt lt tr gt lt A gt lt xsl attribute text gt lt xsl text gt lt tr gt lt xsl apply-templates lt table gt lt xsl template gt lt xsl template match text gt lt xsl template gt lt xsl template match forum gt lt tr gt lt A gt lt xsl attribute lt xsl value-of select name gt lt xsl template gt lt xsl...
Invoking Chat Methods from BonForumStore
BonForumStore contains some methods that are quite specialized for the implementation of a chat application.These methods are used by the processRequest method of BonForumEngine, while it processes threads whose bonForumCommand values are host executes chat or guest executes chat. In the first case, the visitor is starting a chat in the second, the visitor is joining a chat. These BonForumStore methods are invoked when a visitor starts a chat and when visitor joins a chat...
The processRequest Method Initializing bonForumStore
The BonForumEngine class contains a very important member called bonForumStore, which is a static object of the BonForumStore class. It wraps the XML data and provides access to them with its methods. It also provides other methods for use by the BonForumEngine and the JSP-related objects in bonForum. A single instance of it is created by BonForumEngine as follows private static BonForumStore bonForumStore new BonForumStore When we explore the BonForumStore class later, we will see that it...
The BonForumStore Class
Throughout the discussion of the BonForumEngine class, we have seen its dependence on the methods of the BonForumStore class. It is now time to look in more detail at that class. We will not go into as much detail in our discussion because the methods of BonForumStore are less universal in their applicability than those of BonForumEngine. Also, we will discuss only BonForumStore methods that are invoked from outside the class itself, except for a few methods that are helpful for understanding...
