This topic didn’t fit well anywhere else, so we decided to stick it in this chapter since we’re talking about XML so much. The exam doesn’t require you to be an XML expert, but you do have to know two things: the syntax for the key DD elements, and the basics of making what’s known as a JSP Document. (“As opposed to what? If a normal JSP isn’t a document, what is it?” That’s what you’re asking, right? Think of it this way—a normal JSP is a page, unless it’s written with the XML alternatives to normal JSP syntax, in which case it becomes a document.)
All it means is that there are really two types of syntax you can use to make a JSP. The text in grey is the same across both types of syntax.
Normal JSP page syntax | JSP document syntax | |
---|---|---|
Directives (except taglib) |
|
|
Declaration |
| <jsp:declaration> int y = 3; </jsp:declaration> |
Scriptlet |
| <jsp:scriptlet> list.add("Fred"); </jsp:scriptlet> |
Text |
| <jsp:text> There is no spoon. </jsp:text> |
Scripting Expression |
| <jsp:expression> it.next() </jsp:expression> |
This is all the exam covers on JSP Documents.
We aren’t going to say any more about it because writing XML-compliant JSP documents is probably not something you’ll do. The XML syntax is used mainly by tools, and the table above just shows you how the tool would transform your normal JSP syntax into an XML document. There IS more you have to know if you write this by hand—the whole document, for example, is usually enclosed in a <jsp:root> tag (which includes some other stuff), and the taglib directives go inside the <jsp:root> opening tag, rather than as a <jsp:directive>. But everything that might be on the exam is in the table above. So relax.