Write a JSP Document (XML-based document) that uses the correct syntax.

JSP syntax comment:


<%-- comment --%>

					
has no XML syntax analog.

JSP syntax page directive:


<%@ page ... %>

					

XML syntax page directive:


<jsp:directive.page ... />

					

JSP syntax taglib directive:


<%@ taglib ... %>

					
has no XML syntax analog.

jsp:root element is annotated with namespace information:


<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:eg="http://java.apache.org/tomcat/examples-taglib"
	xmlns:test="urn:jsptld:/tomcat/taglib"
	xmlns:temp="urn:jsptld:/WEB-INF/tlds/my.tld"
	version="2.0">

	...

</jsp:root>

					

A taglib directive of the form


<%@ taglib uri="uriValue" prefix="prefix" %>

					
is translated into an xmlns:prefix attribute on the root of the JSP document, with a value that depends on uriValue.
A taglib directive of the form:

<%@ taglib tagdir="tagDirValue" prefix="prefix" %>

					
is translated into an xmlns:prefix attribute on the root of the JSP document, with a value of the form urn:jsptagdir:tagDirValue.

JSP syntax include directive:


<%@ include file="relativeURL" %>

					

XML syntax include directive:


<jsp:directive.include file="relativeURL" />

					
A file on the local system to be included when the JSP page is translated into a servlet. The URL must be a relative one.

JSP syntax declaration:


<%! ... %>

					

XML syntax declaration:


<jsp:declaration> ... </jsp:declaration>

					

Declarations are translated into a jsp:declaration element. For example:


<%! 
	public String someFunc(int i) {
		if (i<3) return("...");
	} 
%>

					
is translated into the following:

<jsp:declaration> 
	<![CDATA[
		public String someFunc(int i) {
			if (i<3) return("...");
		} 
	]]>
</jsp:declaration>

					
Alternatively, we could use an &lt; and instead say:

<jsp:declaration> 
	public String someFunc(int i) { 
		if (i&lt;3) return("..."); 
	} 
</jsp:declaration>

					

JSP syntax scriptlet:


<% ... %>

					

XML syntax scriptlet:


<jsp:scriptlet> ... </jsp:scriptlet>

					

JSP syntax expression:


<%= ... %>

					

XML syntax expression:


<jsp:expression> ... </jsp:expression>

					

JSP syntax template text:


some template text

					

XML syntax template text:


<jsp:text>
	some template text
</jsp:text>

					

A JSP document syntax:


<html>
	<title>positiveTagLib</title>
	<body>
		<%@ taglib uri="http://java.apache.org/tomcat/examples-taglib" 
			prefix="eg" %>
		<%@ taglib uri="/tomcat/taglib" prefix="test" %>
		<%@ taglib uri="WEB-INF/tlds/my.tld" prefix="temp" %>
		<eg:test toBrowser="true" att1="Working">
		Positive Test taglib directive </eg:test>
	</body>
</html>

					

A XML document syntax:


<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:eg="http://java.apache.org/tomcat/examples-taglib"
	xmlns:test="urn:jsptld:/tomcat/taglib"
	xmlns:temp="urn:jsptld:/WEB-INF/tlds/my.tld"
	version="2.0">

	<jsp:text><![CDATA[
<html>
	<title>positiveTagLib</title>
	<body>
	]]></jsp:text>

	<eg:test toBrowser="true" att1="Working">
		<jsp:text>Positive test taglib directive</jsp:text>
	</eg:test>

	<jsp:text><![CDATA[
	</body>
</html>
	]]></jsp:text>

</jsp:root>

					

Professional hosting     Belorussian informational portal         Free SCBCD 1.3 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     Free SCJP 5.0 (Tiger) Study Guide     Free Mock Exam Engine     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide