JSP XML syntax

Why is the JSP XML syntax so badly documented?

In JSP XML syntax, Koert asks...

Isn't it odd that this is so badly documented?

Fair comment. It's documented in the JSP specification, but you won't find much else about it on the web or in books. From my perspective, the reason for this is that nobody actually uses it. Okay, that's a bit of a generalization, but it's mostly true. The XML view of a JSP page is designed to be used programmatically by tools and not to be read/written by humans.

The great thing about the XML view is that it's well-formed XML, which you can parse and transform as necessary. Of course, the major problem is that it's verbose and pretty unreadable. Interestingly, the XML view of a JSP 2.x page can be more readable than its JSP 1.x counterpart. The reason for this is that you have the option to use the integrated expression language support instead of using a mixture of custom tags and runtime expressions translated into their XML equivalents. Still, *I* wouldn't want to actually develop JSP pages in this format and I don't actually remember anybody else using it either! ;-)

Tags :


Re: JSP XML syntax

Gave JSP XML syntax a try whilst JSP 2.0 went through beta. Ok for simple JSP, potentially no harder than "plain" JSP, and neat when it works. But for full mix of JSP, tag libraries, tag files, static/dynamic includes etc there were plenty enough bugs, ambiguities, undocumented interactions/implications against other features of the spec. The actual specification (and reference implementation) bugs got adequately fixed, but it all still felt a bit under-specified. Left me feeling it was just about usable, but I'd always be waiting for the next "gotcha" problem to leap out suddenly. Seemed worth waiting for the spec's coverage of it to mature a bit - if anybody actually uses it enough to drive this. Otherwise think it'll always remain a bit of a fringe area.

Re: JSP XML syntax

I've used it for rss feeds and such in software i've written without any difficulty...

Re: JSP XML syntax

Talking about odd, take a look at this bug:

http://issues.apache.org/bugzilla/show_bug.cgi?id=28207

I just want use   to make my jspx more readable, and the jsp 2.0 specification force me to write whole DTD for the document...

why jsp should do XML validation? and unable to turn it off? I think most people validate XML in development stage, why do it in runtime? isn't that hurt performance?

Re: JSP XML syntax

I've found JSP XML very useful. We've used it quite successfully to provide our own page layout language. Instead of the usual <html><head>...</head>...</html> boiler plate stuff. We just have <page>...</page> and use XSL to preproses the page to output the final JSP. This also allows us to define out own tags which can be replaced with HTML equivlents. Allowing us to have standard blocks of HTML code defined in one place and then just substitued into the page. Components like label, buttons and textfields can have the same look and feel through out the site without having to go throught the pages one by one in order to verify that you've always used the correct css class or remebered to add the title attribute.

Re: JSP XML syntax

jsp xml is awesome. What isn't awesome is how different appservers support it. I love how certain appservers take a snapshot of, say, some ancient tomcat version and embed it deep within itself.

Re: JSP XML syntax

I've used JSP XML for quite a while. There's a couple of benefits that I see. 1. The source (and output) is XML compliant. This is good when using an XML editor, as it helps you detect well-formedness errors during editing. 2. It seems to be a lot faster. This is probably because XML parsing is much faster than plain text parsing. The only thing that really annoyed me, was the fact that you cannot have optional attributes. There is no way to optionally include an attribute on an element, e.g. <option selected="selected"/>. Really stupid. The logic instead has to be around the element (with or without attribute), which can sometimes require either duplicate code, or factoring it out in a tag library (easy with JSP 2.0).

Re: JSP XML syntax

Hi Nils: Is this what you were looking for?
<jsp:element name="option">
    <jsp:attribute name="selected">selected</jsp:attribute>
</jsp:element>

Add a comment Send a TrackBack