1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js" type="text/javascript"></SCRIPT><TITLE>Dynamic XML in Cocoon</TITLE></HEAD><BODY alink="#cc0000" bgcolor="#ffffff" leftmargin="4" link="#039acc" marginheight="4" marginwidth="4" text="#000000" topmargin="4" vlink="#0086b2"><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD align="left" height="60" rowspan="3" valign="top" width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif" vspace="0" width="135"></TD><TD align="left" background="resources/line.gif" colspan="2" height="5" valign="top" width="100%"><IMG align="left" border="0" height="5" hspace="0" src="resources/line.gif" vspace="0" width="1"></TD><TD align="left" height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60" hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD align="left" bgcolor="#0086b2" colspan="2" height="35" valign="top" width="100%"><IMG align="right" alt="" border="0" height="35" hspace="0" src="graphics/dynamic-header.jpg" vspace="0" width="456"></TD></TR><TR><TD align="left" background="resources/bottom.gif" bgcolor="#0086b2" height="20" valign="top" width="100%"><IMG align="left" border="0" height="20" hspace="0" src="resources/bottom.gif" vspace="0" width="3"></TD><TD align="right" background="resources/bottom.gif" bgcolor="#0086b2" height="20" valign="top" width="288"><TABLE border="0" cellpadding="0" cellspacing="0" width="288"><TR><TD align="left" height="20" valign="top" width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');" onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/" border="0" height="20" hspace="0" name="xml" onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');" src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.apache.org/" onMouseOut="rolloverOff('asf');" onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/" border="0" height="20" hspace="0" name="asf" onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');" src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/" onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');" target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0" name="w3c" onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');" src="resources/button-w3c-lo.gif" vspace="0" width="96"></A></TD></TR></TABLE></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD align="left" valign="top" width="120"><IMG border="0" height="14" hspace="0" src="resources/join.gif" vspace="0" width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');" onMouseOver="rolloverOn('side-index');"><IMG alt="Index" border="0" height="12" hspace="0" name="side-index" onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');" src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="license.html" onMouseOut="rolloverOff('side-license');" onMouseOver="rolloverOn('side-license');"><IMG alt="License" border="0" height="12" hspace="0" name="side-license" onLoad="rolloverLoad('side-license','graphics/license-label-2.jpg','graphics/license-label-3.jpg');" src="graphics/license-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="install.html" onMouseOut="rolloverOff('side-install');" onMouseOver="rolloverOn('side-install');"><IMG alt="Install" border="0" height="12" hspace="0" name="side-install" onLoad="rolloverLoad('side-install','graphics/install-label-2.jpg','graphics/install-label-3.jpg');" src="graphics/install-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="install-case-solaris.html" onMouseOut="rolloverOff('side-install-case-solaris');" onMouseOver="rolloverOn('side-install-case-solaris');"><IMG alt="Install on Solaris8" border="0" height="12" hspace="0" name="side-install-case-solaris" onLoad="rolloverLoad('side-install-case-solaris','graphics/install-case-solaris-label-2.jpg','graphics/install-case-solaris-label-3.jpg');" src="graphics/install-case-solaris-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="install-case-windows.html" onMouseOut="rolloverOff('side-install-case-windows');" onMouseOver="rolloverOn('side-install-case-windows');"><IMG alt="Install on Win2k" border="0" height="12" hspace="0" name="side-install-case-windows" onLoad="rolloverLoad('side-install-case-windows','graphics/install-case-windows-label-2.jpg','graphics/install-case-windows-label-3.jpg');" src="graphics/install-case-windows-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="technologies.html" onMouseOut="rolloverOff('side-technologies');" onMouseOver="rolloverOn('side-technologies');"><IMG alt="Technologies" border="0" height="12" hspace="0" name="side-technologies" onLoad="rolloverLoad('side-technologies','graphics/technologies-label-2.jpg','graphics/technologies-label-3.jpg');" src="graphics/technologies-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="infrastructure.html" onMouseOut="rolloverOff('side-infrastructure');" onMouseOver="rolloverOn('side-infrastructure');"><IMG alt="Infrastructure" border="0" height="12" hspace="0" name="side-infrastructure" onLoad="rolloverLoad('side-infrastructure','graphics/infrastructure-label-2.jpg','graphics/infrastructure-label-3.jpg');" src="graphics/infrastructure-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="guide.html" onMouseOut="rolloverOff('side-guide');" onMouseOver="rolloverOn('side-guide');"><IMG alt="User Guide" border="0" height="12" hspace="0" name="side-guide" onLoad="rolloverLoad('side-guide','graphics/guide-label-2.jpg','graphics/guide-label-3.jpg');" src="graphics/guide-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG alt="Dynamic Content" border="0" height="12" hspace="0" src="graphics/dynamic-label-1.jpg" vspace="0" width="120"><BR>
<A href="how-it-works.html" onMouseOut="rolloverOff('side-how-it-works');" onMouseOver="rolloverOn('side-how-it-works');"><IMG alt="How it works" border="0" height="12" hspace="0" name="side-how-it-works" onLoad="rolloverLoad('side-how-it-works','graphics/how-it-works-label-2.jpg','graphics/how-it-works-label-3.jpg');" src="graphics/how-it-works-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="xsp.html" onMouseOut="rolloverOff('side-xsp');" onMouseOver="rolloverOn('side-xsp');"><IMG alt="XSP Processor" border="0" height="12" hspace="0" name="side-xsp" onLoad="rolloverLoad('side-xsp','graphics/xsp-label-2.jpg','graphics/xsp-label-3.jpg');" src="graphics/xsp-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="sqltaglib.html" onMouseOut="rolloverOff('side-sqltaglib');" onMouseOver="rolloverOn('side-sqltaglib');"><IMG alt="SQL XSP Taglib" border="0" height="12" hspace="0" name="side-sqltaglib" onLoad="rolloverLoad('side-sqltaglib','graphics/sqltaglib-label-2.jpg','graphics/sqltaglib-label-3.jpg');" src="graphics/sqltaglib-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="fp.html" onMouseOut="rolloverOff('side-fp');" onMouseOver="rolloverOn('side-fp');"><IMG alt="FP XSP Taglib" border="0" height="12" hspace="0" name="side-fp" onLoad="rolloverLoad('side-fp','graphics/fp-label-2.jpg','graphics/fp-label-3.jpg');" src="graphics/fp-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="connection-pool.html" onMouseOut="rolloverOff('side-connection-pool');" onMouseOver="rolloverOn('side-connection-pool');"><IMG alt="SQL Conn Pool" border="0" height="12" hspace="0" name="side-connection-pool" onLoad="rolloverLoad('side-connection-pool','graphics/connection-pool-label-2.jpg','graphics/connection-pool-label-3.jpg');" src="graphics/connection-pool-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="sql.html" onMouseOut="rolloverOff('side-sql');" onMouseOver="rolloverOn('side-sql');"><IMG alt="SQL Processor" border="0" height="12" hspace="0" name="side-sql" onLoad="rolloverLoad('side-sql','graphics/sql-label-2.jpg','graphics/sql-label-3.jpg');" src="graphics/sql-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="ldap.html" onMouseOut="rolloverOff('side-ldap');" onMouseOver="rolloverOn('side-ldap');"><IMG alt="LDAP Processor" border="0" height="12" hspace="0" name="side-ldap" onLoad="rolloverLoad('side-ldap','graphics/ldap-label-2.jpg','graphics/ldap-label-3.jpg');" src="graphics/ldap-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="dcp.html" onMouseOut="rolloverOff('side-dcp');" onMouseOver="rolloverOn('side-dcp');"><IMG alt="DCP Processor" border="0" height="12" hspace="0" name="side-dcp" onLoad="rolloverLoad('side-dcp','graphics/dcp-label-2.jpg','graphics/dcp-label-3.jpg');" src="graphics/dcp-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="wd-xsp.html" onMouseOut="rolloverOff('side-wd-xsp');" onMouseOver="rolloverOn('side-wd-xsp');"><IMG alt="XSP WD" border="0" height="12" hspace="0" name="side-wd-xsp" onLoad="rolloverLoad('side-wd-xsp','graphics/wd-xsp-label-2.jpg','graphics/wd-xsp-label-3.jpg');" src="graphics/wd-xsp-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="./api/index.html" onMouseOut="rolloverOff('side-ext-48');" onMouseOver="rolloverOn('side-ext-48');"><IMG alt="Javadocs" border="0" height="12" hspace="0" name="side-ext-48" onLoad="rolloverLoad('side-ext-48','graphics/ext-48-label-2.jpg','graphics/ext-48-label-3.jpg');" src="graphics/ext-48-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="cocoon2.html" onMouseOut="rolloverOff('side-cocoon2');" onMouseOver="rolloverOn('side-cocoon2');"><IMG alt="Cocoon 2" border="0" height="12" hspace="0" name="side-cocoon2" onLoad="rolloverLoad('side-cocoon2','graphics/cocoon2-label-2.jpg','graphics/cocoon2-label-3.jpg');" src="graphics/cocoon2-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="faqs.html" onMouseOut="rolloverOff('side-faqs');" onMouseOver="rolloverOn('side-faqs');"><IMG alt="FAQ" border="0" height="12" hspace="0" name="side-faqs" onLoad="rolloverLoad('side-faqs','graphics/faqs-label-2.jpg','graphics/faqs-label-3.jpg');" src="graphics/faqs-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="changes.html" onMouseOut="rolloverOff('side-changes');" onMouseOver="rolloverOn('side-changes');"><IMG alt="Changes" border="0" height="12" hspace="0" name="side-changes" onLoad="rolloverLoad('side-changes','graphics/changes-label-2.jpg','graphics/changes-label-3.jpg');" src="graphics/changes-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-todo');" onMouseOver="rolloverOn('side-todo');"><IMG alt="Todo" border="0" height="12" hspace="0" name="side-todo" onLoad="rolloverLoad('side-todo','graphics/todo-label-2.jpg','graphics/todo-label-3.jpg');" src="graphics/todo-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="livesites.html" onMouseOut="rolloverOff('side-livesites');" onMouseOver="rolloverOn('side-livesites');"><IMG alt="Live Sites" border="0" height="12" hspace="0" name="side-livesites" onLoad="rolloverLoad('side-livesites','graphics/livesites-label-2.jpg','graphics/livesites-label-3.jpg');" src="graphics/livesites-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
<A href="http://xml.apache.org/websrc/index.cgi/xml-cocoon/" onMouseOut="rolloverOff('side-ext-68');" onMouseOver="rolloverOn('side-ext-68');"><IMG alt="Code Repository" border="0" height="12" hspace="0" name="side-ext-68" onLoad="rolloverLoad('side-ext-68','graphics/ext-68-label-2.jpg','graphics/ext-68-label-3.jpg');" src="graphics/ext-68-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="http://xml.apache.org/from-cvs/xml-cocoon/" onMouseOut="rolloverOff('side-ext-70');" onMouseOver="rolloverOn('side-ext-70');"><IMG alt="Dev Snapshots" border="0" height="12" hspace="0" name="side-ext-70" onLoad="rolloverLoad('side-ext-70','graphics/ext-70-label-2.jpg','graphics/ext-70-label-3.jpg');" src="graphics/ext-70-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="mail-lists.html" onMouseOut="rolloverOff('side-mail-lists');" onMouseOver="rolloverOn('side-mail-lists');"><IMG alt="Mail Lists" border="0" height="12" hspace="0" name="side-mail-lists" onLoad="rolloverLoad('side-mail-lists','graphics/mail-lists-label-2.jpg','graphics/mail-lists-label-3.jpg');" src="graphics/mail-lists-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="http://mail-archives.apache.org/" onMouseOut="rolloverOff('side-ext-74');" onMouseOver="rolloverOn('side-ext-74');"><IMG alt="Mail Archive" border="0" height="12" hspace="0" name="side-ext-74" onLoad="rolloverLoad('side-ext-74','graphics/ext-74-label-2.jpg','graphics/ext-74-label-3.jpg');" src="graphics/ext-74-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0" width="120"><BR></TD><TD align="left" valign="top" width="*"><TABLE border="0" cellpadding="3" cellspacing="0"><TR><TD><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>Introduction</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">Web publishing is very limited without the ability to create
dynamic content. By dynamic XML we mean the content that is created as a
function of request parameters or state of the requested resource. For this
reason, a lot of work and design has been put into Cocoon to allow dynamic XML
content to be generated.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>The Servlet/JSP model</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">People are used to writing small Java programs to create their
dynamic web content. Servlets, and Java in general, are very powerful, easy to
write and fast to debug, but they impose (like any other pure-logic solution)
a significant management cost. This is due to the fact that programmable
components like servlets must include both the logic to generate the dynamic
code as well as all static elements (such as static content and style). The
need for a more useful solution soon appeared.</P>
<P align="justify">To fill the gap between Java programmers and web engineers (groups
that rarely overlap), Sun proposed the Java Server Pages (JSP) specification,
a markup language (today with both SGML and XML syntax) that allows web
engineers to include code in their pages, rather than include pages in their
code. The impact of this strategy was significant: servlets were written
directly in Java code if very little static content was to be used, otherwise
JSP or other compiled server pages technologies were used.</P>
<P align="justify">This said, it would seem that using servlets/JSPs to create
dynamic XML content would be the perfect choice. Unfortunately, design issues
indicate that we should take a second look at the technology, and understand why
this isn't so.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>Servlet Chaining Vs. Servlet Nesting</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">Java Servlets were introduced by the Java Web Server team as a
way to allow users to create their own <I>web plug-ins</I>. They were designed
to handle the HTTP protocol and all possible dynamic web content (including
HTML, XML, images, etc. - both text and binary streams). Unfortunately, the need
for a componentized request handler was not taken into serious consideration
in the design phase but only later, when at an implementation phase.</P>
<P align="justify">In fact, the Java Web Server provided the ability to <I>chain</I>
multiple servlets, one becoming the filter of the other. Unfortunately, since
the API doesn't include such a possibility in its design, such a servlet chain is
very limited in its behavior and puts significant restrictions on the API use.
Something that forced the Servlet API architects to come up with better
solutions.</P>
<P align="justify">The solution was <I>servlet nesting</I>: the ability for a servlet to
include another servlet's output inside its own transparently. This allowed
programmers to separate different logic on different servlets, thus removing
the need for servlet chaining.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>The limitations of Servlet Nesting</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">While servlet nesting was a major advantage over servlet
chaining because it allowed servlets to be somewhat modular without losing
the full API power, a common design pattern applies to the Servlet model in
general: no servlet is allowed to modify the output of another servlet. This
holds true for all servlet API versions up to today (version 2.2).</P>
<P align="justify">This limitation is the key: if no further XML processing is
needed on the server side, using servlets/JSP for creating XML is a perfect
choice, but if this output requires some server side processing (for example
XSLT transformations), the Servlet API does not allow another servlet to
post-process it's output. This other servlet is, in our case, Cocoon.</P>
<P align="justify">In a few words, the Servlet API doesn't support <I>Servlet
Piping</I>.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>The Cocoon Model</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">Rather than turning Cocoon into a servlet engine, thus
limiting its portability, this document outlines some solutions that allow
Cocoon users to get the servlet-equivalent functionality with internal Cocoon
design ideas.</P>
<P align="justify">The Cocoon processing model is based on the separation of</P>
<BLOCKQUOTE><DL>
<LI><STRONG>Production</STRONG> - </LI>
where XML content is generated based on Request parameters
(servlet equivalent)
<LI><STRONG>Processing</STRONG> - </LI>
where the produced XML content is transformed/evaluated
<LI><STRONG>Formatting</STRONG> - </LI>
where the XML content is finally formatted into the desired output format
for client use.
</DL></BLOCKQUOTE>
<P align="justify">This separation of working contexts allows Cocoon users to
implement their own internal modules to add the functionality they require to
the whole publishing system. In fact, while a few of these components are
already shipped with Cocoon, the highly modular structure allows you to build
your own to fit your particular needs.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>Writing Producers</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">Producers initiate the request handling phase. They are
responsible for evaluating the HttpServletRequest parameters provided and create
XML content that is fed into the processing reactor. Servlet logic should be
translated into a producer if the request parameters can be used directly to
generate the XML content (for example the FileProducer which loads the
requested file from disk).</P>
<P align="justify">Here follows the code for an example producer distributed with
Cocoon:</P>
<DIV align="center"><TABLE border="0" cellpadding="0" cellspacing="4"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff"><PRE>
public class DummyProducer
extends AbstractProducer
implements Status
{
String dummy = "<?xml version=\"1.0\"?>"
+ "<?cocoon-format type=\"text/html\"?>"
+ "<html><body>"
+ "<h1 align=\"center\">"
+ "Hello from a dummy page"
+ "</h1>"
+ "</body></html>";
public Reader getStream(HttpServletRequest request)
throws IOException
{
return new StringReader(dummy);
}
public String getPath(HttpServletRequest request) {
return "";
}
public String getStatus() {
return "Dummy Producer";
}
}
</PRE></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
<P align="justify">The key method is <CODE><FONT face="courier, monospaced">getStream()</FONT></CODE> which is responsible for
processing the given servlet request and provide a Reader for reading the
generated XML document.</P>
<P align="justify">Note that AbstractProducer has also another method,
<CODE><FONT face="courier, monospaced">getDocument(request)</FONT></CODE>, which is responsible for directly returning a
DOM tree. In case you need to render your servlet code Cocoon-aware, the above
example should tell you what to do.</P>
<P align="justify">Please look at the shipped producers' source code for example
code and look at the <A href="guide.html">user guide</A> for how to
install and use your own producers.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>Writing Processors</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">If your servlet needs many parameters to work, it is more
reasonable that you write a Processor instead. A Processor transforms a given
XML document (which, in this case should contain the needed static parameters)
into something else, driven both by the input document and by the request
object which is also available.</P>
<P align="justify">Here is a simple processor example that should show you what
the above means. Suppose you have the following document as input (note that
it may have been produced from a file, from other sources or dynamically - see
the above paragraph):</P>
<DIV align="center"><TABLE border="0" cellpadding="0" cellspacing="4"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff"><PRE>
<?xml version="1.0"?>
<page>
<p>Current time is <time/></p>
</page>
</PRE></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
<P align="justify">Our simple example processor will look for the <time/> tags and will
expand them to the current local time, creating this result document:</P>
<DIV align="center"><TABLE border="0" cellpadding="0" cellspacing="4"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff"><PRE>
<?xml version="1.0"?>
<page>
<p>Current time is 6:48PM</p>
</page>
</PRE></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
<P align="justify">Please look at the shipped processors' source code for example
code and look at the <A href="guide.html">user guide</A> for how to
install and use your own processors.</P>
</FONT></TD></TR></TABLE></DIV><BR>
<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>Using Cocoon processors</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
<P align="justify">The above example shows a very simple situation but needs
non-trivial code to implement it. For this reason, the Cocoon distribution
includes a number of processors that implement common needs and situations.
These are:</P>
<BLOCKQUOTE><DL>
<LI><STRONG>The XSLT processor</STRONG> - </LI>
Applies XSLT
transformations to the input document. XSLT allows you to solve your
transformation needs as well as simple tag evaluation/processing due to
its extensible and programmable nature. XSLT is a W3C Recommendation.
<LI><STRONG>The XSP processor</STRONG> - </LI>
Evaluates XSP pages and compiles them into
producers. This processor allows you include programmatic logic into
your pages as well as to separate the logic from the content. See the
<A href="xsp-primer.html
">XSP user guide</A> for more information.
Note that the XSP Processor assumes that it is getting its input from a static
file, so it will not work well with pre-processing. Its design means that
it should really have been a Producer in the first place, instead of
a Processor. This change has been made in Cocoon 2.
<LI><STRONG>The DCP processor (Deprecated)</STRONG> - </LI>
Evaluates XML processing
instructions with multi-language (Java and EcmaScript) logic. This
processor allows you to do programmatic substitution and inclusion
eliminating the need for complex processing logic. See the <A href="dcp.html">DCP
user guide</A> for more information. Note: This is deprecated -
users are advised to use the more powerful
<A href="xsp-primer.html
">XSP processor</A> instead.
<LI><STRONG>The SQL processor (Deprecated)</STRONG> - </LI>
Evaluates simple tags
describing SQL queries to JDBC drivers and formats their result-set in XML
depending on given parameters. See the <A href="sql.html">SQL
processor user guide</A> for more information. Note: This is deprecated -
users are advised to use the
<A href="sqltaglib.html">XSP SQL taglib</A>, or the more
powerful <A href="esql.html
">Extended SQL taglib</A> instead.
The latter (ESQL taglib) allows easy post-processing of output within XSP,
amongst other things, whilst the former taglib is mainly provided for backward
compatability.
<LI><STRONG>The LDAP processor</STRONG> - </LI>
the <I>LDAP</I> processor that evaluates simple tags
describing LDAP queries to directory services and formats their result-set in XML
depending on given parameters. See the <A href="ldap.html">LDAP
processor user guide</A> for more information.
</DL></BLOCKQUOTE>
</FONT></TD></TR></TABLE></DIV><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD bgcolor="#0086b2"><IMG height="1" src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT color="#0086b2" face="arial,helvetica,sanserif" size="-1"><I>
Copyright © 1999-2000 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
|