WAS (J2EE) Functions Compared to Domino
In this section, we discuss the main areas where WAS and Domino overlap in function and present the conventional wisdom (and our view) about using one over the other.
Servlets vs. Web Agents
At a high level, J2EE servlets and Domino Web agents are pretty much equivalentthey provide a means to run server-side programs triggered by client-side (browser) events. The Domino "Web agent" function is new with Domino 6 and basically extends the traditional Domino agent function to include triggering from Web events. The traditional Domino agent was restricted to server-side programs triggered by time or by Domino database events. Both servlets and Web agents can return HTML to the client.
Domino Web agents can be coded in either Java or the Domino-specific languages of LotusScript, formulas, or simple actions. In fact, Web agents are the only context in which LotusScript may be used for Web applications. Thus, Web agents may be easier to implement for Domino developers. The Web agent, since it runs as part of the Domino server, has direct access to Domino data elements. The biggest drawback to using Web agents for server-side functions is that the agent must be loaded each time it is invoked. This is done by the Domino agent manager, which does not provide for agent caching. For Web agents written in Java, an entire JVM must be started to run the agent. If the design calls for frequent use of the agent, loading on each invocation usually leads to unacceptable performance.
Servlets, on the other hand, are architected to be run efficiently by the J2EE application server. Servlets are loaded either on server start or on first invocation of the servlet and are simply passed subsequent requests by the application server. If the servlet function needs to access Domino resources, this can be accomplished via the Domino Objects for Java. The servlet designer has a choice of how Domino is accessed, which can be either locally (where Domino is running on the same server as WAS) or remotely. Naturally, there is overhead in accessing Domino remotely, but this can be tailored so that the access is not needed for each servlet invocation. We discuss strategies for accessing Domino via Java and J2EE in more detail in Chapter 10, "Accessing Domino from J2EE."
Which to choose then? We usually adhere to the common guideline of implementing server-side functions as servlets, especially when the functions will be invoked frequently. If the functions are infrequent and require a fair amount of or sophisticated Domino processing, then Web agents are appropriate.
Java Server Pages (JSPs) vs. Domino Forms
Another area of overlapping function between WAS and Domino is the ability to generate and process HTML content, especially forms. A designer can include forms in a Web application by using either JSPs managed by WAS or Domino database forms served by the Domino HTTP engine. A third possibility is available now with the support for Domino Custom JSP tags, where any Domino database form can be converted into a JSP and handled by WAS.
The choice between WAS and Domino here is not clear-cut. There are several factors that could affect the decision. Probably the most influential ones are the following:
Overall application look and feel. If the application is predominantly JSP- or Domino-based, then it makes sense to stay with the same rendering. Although if there is any JSP content, it may be easier to convert Domino Web content to JSPs rather than the other way around.
Development skills. If the development experience lies with one product, then it will likely cost less to develop using that product.
Unique feature rendering. There are certain cases where attempting to convert a Domino form to a JSP will not be of perfect fidelity. This can occur when using the Domino Custom JSP tags. (In Chapter 10, we discuss ways to generate JSPs from Domino forms with greater fidelity.)
WAS vs. Domino Servlet Engine
Before the advent of WAS, the Domino server product provided a means for plugging in a servlet engine to handle servlets in addition to the standard Domino resources. So, there is the possibility of using a servlet engine under Domino versus WAS for servlet processing. The choice here is clear-cut. WAS should handle all J2EE resources. It's difficult to concieve of any advantage to having Domino handle servlets.