author | František Kučera <franta-hg@frantovo.cz> |
Wed Jan 27 01:28:52 2010 +0100 (2010-01-27) | |
changeset 23 | f76fc9f3cb7c |
parent 12 | fceba17855e9 |
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 |
<!-- vypíšeme si parametr zadaný uživatelem, ale ošetříme ho, |
franta-hg@12 | 29 |
aby nám nezbořil naši pěknou XHTML stránku --> |
franta-hg@12 | 30 |
<p><c:out value="${param.parametr1}" escapeXml="true"/></p> |
franta-hg@12 | 31 |
<!-- escapeXml="true" nemusíme psát – to je výchozí hodnota --> |
franta-hg@12 | 32 |
|
franta-hg@12 | 33 |
<p>Když potřebujeme dát |
franta-hg@12 | 34 |
<abbr title="${fn:escapeXml(param.parametr1)}">„escapovaný“</abbr> |
franta-hg@12 | 35 |
text do atributu, použijeme funkci <code>escapeXml()</code> ze jmenného prostoru:</p> |
franta-hg@12 | 36 |
<pre>xmlns:fn="http://java.sun.com/jsp/jstl/functions"</pre> |
franta-hg@12 | 37 |
|
franta-hg@12 | 38 |
</body> |
franta-hg@12 | 39 |
</html> |
franta-hg@12 | 40 |
|
franta-hg@12 | 41 |
</jsp:root> |