tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: where to parse xml files
Date Mon, 19 Aug 2002 05:06:02 GMT
On Mon, 19 Aug 2002, hdi12 wrote:

> I have a question about parsing XML documents in JSTL. JSTL provides
> xml tags that allows paseing xml document directly in the JSP pages.
> In standard JSP, the xml parsing is always done in Java classes, and
> JSP puts the result into the pages. The latter approach can also be
> applied in JSTL. I am not very sure which approach is much better
> (more efficient)? Can anyone give some suggestion?

I'm not sure what you mean by "standard JSP."  It is conventional, in many
circles, to adopt an approach based on patterns like Model-View-Controller
(MVC), which would suggest avoiding the development of a single component
that handles data-oriented tasks (parsing an XML document) and
presentation-oriented ones (printing some parts of it).  Such approaches
are generally well regarded, but they are neither universal nor mandatory.

So you're free to choose either approach.  JSTL's XML tags let you parse a
document so the tags can be self sufficient.  This lets you avoid having
to write back-end component like a servlet or filter to parse an XML
document; such a shortcut can be convenient if you're writing a small
application or, say, a single page whose job is simply to display some
XML-based data.

In a larger application, you might ignore the <x:parse> tag and perhaps
even the <x:set> tag -- and simply use the tags whose purpose is to
display data (<x:out>) or control the flow in a page (<x:if>, <x:forEach>,
etc.).  Your back-end components would handle the parsing of XML documents
and perhaps some complex manipulations as well.

There likely won't be a significant difference in runtime performance
between the two approaches; you of course have more control when writing
Java code yourself, but you can't make a general statement about whether
code will be faster in front-end or back-end components.  The important
consideration as far as efficiency is concerned is the efficiency of
developers -- that is, how quickly and effectively you can write your
application.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message