author | František Kučera <franta-hg@frantovo.cz> |
Fri, 08 Jan 2010 01:54:47 +0100 | |
changeset 12 | fceba17855e9 |
child 13 | 626c57d1fc3b |
permissions | -rw-r--r-- |
franta-hg@12 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
franta-hg@12 | 2 |
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" |
franta-hg@12 | 3 |
xmlns:c="http://java.sun.com/jsp/jstl/core" |
franta-hg@12 | 4 |
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" |
franta-hg@12 | 5 |
xmlns:fn="http://java.sun.com/jsp/jstl/functions" |
franta-hg@12 | 6 |
version="2.0"> |
franta-hg@12 | 7 |
<jsp:directive.page contentType="application/xhtml+xml"/> |
franta-hg@12 | 8 |
<jsp:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" |
franta-hg@12 | 9 |
doctype-root-element="html" |
franta-hg@12 | 10 |
omit-xml-declaration="false"/> |
franta-hg@12 | 11 |
|
franta-hg@12 | 12 |
|
franta-hg@12 | 13 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
franta-hg@12 | 14 |
<head> |
franta-hg@12 | 15 |
<title>Escapování</title> |
franta-hg@12 | 16 |
</head> |
franta-hg@12 | 17 |
<body> |
franta-hg@12 | 18 |
<h1>Escapování</h1> |
franta-hg@12 | 19 |
<h2>Vstup</h2> |
franta-hg@12 | 20 |
<!-- jednoduchý formulář na otestování uživatelského vstupu --> |
franta-hg@12 | 21 |
<form action="escapovani.jsp" method="post"> |
franta-hg@12 | 22 |
<fieldset> |
franta-hg@12 | 23 |
<input name="parametr1" type="text"/> |
franta-hg@12 | 24 |
<button>Odeslat!</button> |
franta-hg@12 | 25 |
</fieldset> |
franta-hg@12 | 26 |
</form> |
franta-hg@12 | 27 |
<h2>Výstup</h2> |
franta-hg@12 | 28 |
<jsp:scriptlet> |
franta-hg@12 | 29 |
Integer x = null; |
franta-hg@12 | 30 |
x.toString(); |
franta-hg@12 | 31 |
</jsp:scriptlet> |
franta-hg@12 | 32 |
<!-- vypíšeme si parametr zadaný uživatelem, ale ošetříme ho, |
franta-hg@12 | 33 |
aby nám nezbořil naši pěknou XHTML stránku --> |
franta-hg@12 | 34 |
<p><c:out value="${param.parametr1}" escapeXml="true"/></p> |
franta-hg@12 | 35 |
<!-- escapeXml="true" nemusíme psát – to je výchozí hodnota --> |
franta-hg@12 | 36 |
|
franta-hg@12 | 37 |
<p>Když potřebujeme dát |
franta-hg@12 | 38 |
<abbr title="${fn:escapeXml(param.parametr1)}">„escapovaný“</abbr> |
franta-hg@12 | 39 |
text do atributu, použijeme funkci <code>escapeXml()</code> ze jmenného prostoru:</p> |
franta-hg@12 | 40 |
<pre>xmlns:fn="http://java.sun.com/jsp/jstl/functions"</pre> |
franta-hg@12 | 41 |
|
franta-hg@12 | 42 |
</body> |
franta-hg@12 | 43 |
</html> |
franta-hg@12 | 44 |
|
franta-hg@12 | 45 |
</jsp:root> |