Baer, Jon wrote:
> I havent followed the thread closely but couldnt u just post another tag?
> (I think this might just be a JRun feature), either that or just write ur
> own class.
>
> The best best would be to write your own <TAG> that included all your header
> features, etc, and then do a out.println("<MYTAG OPTION=Whatever></MYTAG>");
>
All JSP engines that are compliant with the JSP 1.1 specification will allow you
to create new "tag libraries" that support custom functionality like this -- or
use such tag libraries created by others. The examples included with the JSP
1.1 spec cover a broad range of possibilities that only scratch the surface of
what can be done:
* Looping constructs using tags instead of Java scriptlets
* A <usebean> tag like the one in JSP 0.92, which executes processRequest()
when used in a page
* SQL connection and query tags
"Legacy" servlet-based apps (that is, all of a year ago or so :-) have the
servlet generating the HTML code, using out.println() or some other similar
mechanism. I can tell you from experience -- it is quite painful to maintain
and enhance such an application, because the display logic (HTML generation) is
embedded in the business logic. And it is incredibly easy to start generating
invalid HTML as you add new things.
If you're going to use servlets to generate your HTML, I would suggest using a
package like ECS, or something based on the Document Object Model from W3C (the
standards body that defines what "standard HTML" is). Either of these let you
deal with the HTML in an object-oriented style, without having to worry about
the nit-picky syntax. The other benefit you get is that these packages will do
tedious things like adding the corresponding end tags (<td> ... </td>) for you,
which makes it easier to create HTML that strictly conforms to the standard.
However, there is a different application style that you should study and
understand -- separation of the business logic and the presentation logic. You
can do it with pure servlets if you want:
HTML Form --> Business Logic Servlet --> Beans --> Forward to Display
Servlet
or with a JSP/template solution:
HTML Form --> Business Logic Servlet --> Beans --> Forward to JSP Display
(or template system display)
or
HTML Form --> Business Logic Template Page --> Beans --> Forward to Display
Template Page
The key principle is that the "business logic" only cares about interacting with
your database, doing the user transactions, or whatever is necessary. These
modules do *not* generate any HTML for the response -- they only capture the
results of these interactions, store them in beans, and forward them to a module
(JSP page, template page, servlet generating HTML, or whatever) whose *only*
purpose is to generate the output.
IMHO, anyone who is using out.println("...") in a servlet to generate HTML is
working too hard -- no matter what syntax shortcuts you can come up with. :-)
But you have to be willing to think about generating dynamic content in a new
way -- and trying to use an approach optimized for CGI scripts (a PERL-style
"print qq"), where the module executes once and then goes away, is not that new
way.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html