You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2002/01/24 17:11:44 UTC
cvs commit: jakarta-tomcat-4.0/webapps/examples/jsp/xml xml.html xml.jsp xml.txt
remm 02/01/24 08:11:44
Added: webapps/examples/jsp/xml xml.html xml.jsp xml.txt
Log:
- Add XML syntax example, contributed by Mike Los (mike.los at storigen.com).
Revision Changes Path
1.1 jakarta-tomcat-4.0/webapps/examples/jsp/xml/xml.html
Index: xml.html
===================================================================
<html>
<!--
Copyright (c) 2002 The Apache Software Foundation. All rights
reserved.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="xml.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="xml.txt">Source Code for XML syntax Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>
1.1 jakarta-tomcat-4.0/webapps/examples/jsp/xml/xml.jsp
Index: xml.jsp
===================================================================
<?xml version="1.0"?>
<jsp:root xmlns="http://java.sun.com/JSP/Page"
version="1.2">
<jsp:directive.page contentType="text/html"/>
<jsp:directive.page import="java.util.Date, java.util.Locale"/>
<jsp:directive.page import="java.text.*"/>
<jsp:declaration>
String getDateTimeStr(Locale l) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l);
return df.format(new Date());
}
</jsp:declaration>
<html>
<head>
<title>Example JSP in XML format</title>
</head>
<body>
This is the output of a simple JSP using XML format.
<br />
<div>Use a jsp:scriptlet to loop from 1 to 10: </div>
<jsp:scriptlet>
// Note we need to declare CDATA because we don't escape the less than symbol
<![CDATA[
for (int i = 1; i<=10; i++) {
out.println(i);
if (i < 10) {
out.println(", ");
}
}
]]>
</jsp:scriptlet>
<!-- Because I omit br's end tag, declare it as CDATA -->
<![CDATA[
<br><br>
]]>
<div align="left">
Use a jsp:expression to write the date and time in the browser's locale:
<jsp:expression>getDateTimeStr(request.getLocale())</jsp:expression>
</div>
<jsp:text>
<p>This sentence is enclosed in a jsp:text element.</p>
</jsp:text>
</body>
</html>
</jsp:root>
1.1 jakarta-tomcat-4.0/webapps/examples/jsp/xml/xml.txt
Index: xml.txt
===================================================================
<?xml version="1.0"?>
<jsp:root xmlns="http://java.sun.com/JSP/Page"
version="1.2">
<jsp:directive.page contentType="text/html"/>
<jsp:directive.page import="java.util.Date, java.util.Locale"/>
<jsp:directive.page import="java.text.*"/>
<jsp:declaration>
String getDateTimeStr(Locale l) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l);
return df.format(new Date());
}
</jsp:declaration>
<html>
<head>
<title>Example JSP in XML format</title>
</head>
<body>
This is the output of a simple JSP using XML format.
<br />
<div>Use a jsp:scriptlet to loop from 1 to 10: </div>
<jsp:scriptlet>
// Note we need to declare CDATA because we don't escape the less than symbol
<![CDATA[
for (int i = 1; i<=10; i++) {
out.println(i);
if (i < 10) {
out.println(", ");
}
}
]]>
</jsp:scriptlet>
<!-- Because I omit br's end tag, declare it as CDATA -->
<![CDATA[
<br><br>
]]>
<div align="left">
<!-- If we don't use <span> or <jsp:text> or any other tag to enclose the label,
then the date/time string is printed BEFORE the label. Is this a Tomcat 4.0.1 bug? -->
<div>
Use a jsp:expression to write the date and time in the browser's locale:
</div>
<jsp:expression>getDateTimeStr(request.getLocale())</jsp:expression>
</div>
<jsp:text>
<p>This sentence is enclosed in a jsp:text element.</p>
</jsp:text>
</body>
</html>
</jsp:root>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>