franta-hg@83: <?xml version="1.0" encoding="UTF-8"?> franta-hg@83: <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" franta-hg@83: xmlns:c="http://java.sun.com/jsp/jstl/core" franta-hg@83: xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" franta-hg@83: xmlns:fn="http://java.sun.com/jsp/jstl/functions" franta-hg@83: xmlns:nk="urn:jsptagdir:/WEB-INF/tags/nekurak" franta-hg@83: version="2.0"> franta-hg@83: franta-hg@83: <jsp:directive.page contentType="application/xhtml+xml"/> franta-hg@83: franta-hg@83: <!-- <lokalizace> --> franta-hg@83: <c:if test="${param.jazyk != null}"> franta-hg@83: <fmt:setLocale value="${param.jazyk}" scope="session"/> franta-hg@83: </c:if> franta-hg@83: <fmt:setBundle basename="cz.frantovo.nekurak.preklady" scope="application"/> franta-hg@83: <!-- </lokalizace> --> franta-hg@83: franta-hg@83: <nk:stranka titulek="Kaptcha"> franta-hg@83: franta-hg@83: <h1><c:out value="Kaptcha – ukázka"/></h1> franta-hg@83: franta-hg@83: <c:choose> franta-hg@83: <c:when test="${param.akce == 'odeslat'}"> franta-hg@83: <p>Odeslané údaje:</p> franta-hg@83: franta-hg@83: <p>Políčko 1: <c:out value="${param.policko1}"/></p> franta-hg@83: <p>Políčko 2: <c:out value="${param.policko2}"/></p> franta-hg@83: <p>Kaptcha: <c:out value="${param.kaptcha}"/></p> franta-hg@83: franta-hg@83: <p>Očekávaná hodnota: <c:out value="${sessionScope['KAPTCHA_SESSION_KEY']}"/></p> franta-hg@83: franta-hg@83: <c:choose> franta-hg@83: <c:when test="${sessionScope['KAPTCHA_SESSION_KEY'] == param.kaptcha}"> franta-hg@83: <p class="informacniHlaska">Správně opsaný kód z obrázku.</p> franta-hg@83: </c:when> franta-hg@83: <c:otherwise> franta-hg@83: <p class="chybovaHlaska">Špatně obsaný kód z obrázku.</p> franta-hg@83: </c:otherwise> franta-hg@83: </c:choose> franta-hg@83: franta-hg@83: franta-hg@83: franta-hg@83: </c:when> franta-hg@83: <c:otherwise> franta-hg@83: <!-- Zobrazíme uživateli registrační formulář. --> franta-hg@83: <p>Nějaký formulář, který chceme ochránit proti spamu:</p> franta-hg@83: <form method="post" action="kaptcha.jsp?akce=odeslat"> franta-hg@83: <fieldset> franta-hg@83: <label>Políčko 1: <input type="text" name="policko1" maxlength="255"/></label><br/> franta-hg@83: <label>Políčko 2: <input type="text" name="policko2" maxlength="255"/></label><br/> franta-hg@83: </fieldset> franta-hg@83: <fieldset> franta-hg@83: <!-- Kaptcha --> franta-hg@83: <img src="kaptcha.jpg" alt="ochrana proti spamu" id="kaptchaIMG" title="klikněte pro vygenerování nového obrázku"/><br/> franta-hg@83: <script type="text/javascript"> franta-hg@83: $(function(){ franta-hg@83: $('#kaptchaIMG').click(function () { $(this).attr('src', 'kaptcha.jpg?' + Math.floor(Math.random()*100) ); }) franta-hg@83: }); franta-hg@83: </script> franta-hg@83: franta-hg@83: <label>Opište: <input type="text" name="kaptcha" maxlength="255"/></label><br/> franta-hg@83: </fieldset> franta-hg@83: <fieldset> franta-hg@83: <button value="submit">Odeslat</button> franta-hg@83: </fieldset> franta-hg@83: </form> franta-hg@83: </c:otherwise> franta-hg@83: </c:choose> franta-hg@83: franta-hg@83: </nk:stranka> franta-hg@83: franta-hg@83: </jsp:root>