<%-- Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. --%> <?xml version="1.0"?> <html xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:fmt="http://java.sun.com/jstl/fmt" version="1.2"> <jsp:directive.page contentType="text/html"/> <jsp:directive.page import="java.util.*"/> <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> <fmt:setBundle basename="LocalStrings"/> <html> <head> <title><fmt:message key="xml.jsp.title"/></title> </head> <body> <fmt:message key="xml.jsp.output"/> <br /> <div><fmt:message key="xml.jsp.loop"/> </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"> <fmt:message key="xml.jsp.expressione"/> <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> </html>