source: nutchez-0.1/tomcat/webapps/examples/jsp/xml/xml.jsp.html

Last change on this file was 66, checked in by waue, 16 years ago

NutchEz - an easy way to nutch

File size: 2.2 KB
Line 
1<html><body><pre>
2&lt;?xml version="1.0"?>
3&lt;!--
4 Licensed to the Apache Software Foundation (ASF) under one or more
5  contributor license agreements.  See the NOTICE file distributed with
6  this work for additional information regarding copyright ownership.
7  The ASF licenses this file to You under the Apache License, Version 2.0
8  (the "License"); you may not use this file except in compliance with
9  the License.  You may obtain a copy of the License at
10
11      http://www.apache.org/licenses/LICENSE-2.0
12
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18-->
19&lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
20  version="1.2">
21&lt;jsp:directive.page contentType="text/html"/>
22&lt;jsp:directive.page import="java.util.Date, java.util.Locale"/>
23&lt;jsp:directive.page import="java.text.*"/>
24
25&lt;jsp:declaration>
26  String getDateTimeStr(Locale l) {
27    DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l);
28    return df.format(new Date());
29  }
30&lt;/jsp:declaration>
31
32&lt;html>
33&lt;head>
34  &lt;title>Example JSP in XML format&lt;/title>
35&lt;/head>
36
37&lt;body>
38This is the output of a simple JSP using XML format.
39&lt;br />
40
41&lt;div>Use a jsp:scriptlet to loop from 1 to 10: &lt;/div>
42&lt;jsp:scriptlet>
43// Note we need to declare CDATA because we don't escape the less than symbol
44&lt;![CDATA[
45  for (int i = 1; i&lt;=10; i++) {
46    out.println(i);
47    if (i &lt; 10) {
48      out.println(", ");
49    }
50  }
51]]>
52&lt;/jsp:scriptlet>
53
54&lt;!-- Because I omit br's end tag, declare it as CDATA -->
55&lt;![CDATA[
56  &lt;br>&lt;br>
57]]>
58
59&lt;div align="left">
60  Use a jsp:expression to write the date and time in the browser's locale:
61  &lt;jsp:expression>getDateTimeStr(request.getLocale())&lt;/jsp:expression>
62&lt;/div>
63
64
65&lt;jsp:text>
66  &amp;lt;p&amp;gt;This sentence is enclosed in a jsp:text element.&amp;lt;/p&amp;gt;
67&lt;/jsp:text>
68
69&lt;/body>
70&lt;/html>
71&lt;/jsp:root>
72</pre></body></html>
Note: See TracBrowser for help on using the repository browser.