Commit 6bfd981e by Patryk Czarnik

JSP2 - beany

parent bf5e6d85
...@@ -8,6 +8,7 @@ target/ ...@@ -8,6 +8,7 @@ target/
.idea/jarRepositories.xml .idea/jarRepositories.xml
.idea/compiler.xml .idea/compiler.xml
.idea/libraries/ .idea/libraries/
.idea/webContexts.xml
*.iws *.iws
*.iml *.iml
*.ipr *.ipr
......
...@@ -2,47 +2,50 @@ ...@@ -2,47 +2,50 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pl.alx.kjava</groupId> <groupId>pl.alx.kjava</groupId>
<artifactId>PC23-Servlety</artifactId> <artifactId>PC23-Servlety</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<name>PC23-Servlety</name> <name>PC23-Servlety</name>
<packaging>war</packaging> <packaging>war</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<junit.version>5.9.2</junit.version> <junit.version>5.9.2</junit.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>jakarta.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version> <version>5.0.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>${junit.version}</version> <version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency> </dependencies>
<build> </dependency>
<!-- stara klasyczna wersja - tylko dla starszych serwerów -->
<!-- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
-->
</dependencies>
<build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version> <version>3.3.2</version>
</plugin> </plugins> </plugin>
</build> </plugins>
</build>
</project> </project>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<html> <html>
<head> <head>
<title>Przyklad 2 JSP</title> <title>Przyklad 2 JSP</title>
...@@ -35,5 +36,22 @@ ...@@ -35,5 +36,22 @@
Gdy wpiszemy coś z nawiasami na końcu, to jest to wywołanie metody, Gdy wpiszemy coś z nawiasami na końcu, to jest to wywołanie metody,
--%> --%>
<%-- Biblioteka tagów ("taglib") to jest zestaw poleceń zapisywanych w formie znaczników w obrębie JSP.
Te znaczniki zawsze są poprzedzane prefiksem, np. <c:if>....
Tagliby można definiować samodzielnie, ale w 98% przypadków używa się zestawu nazywanego JSTL
"Java Standard Tag Library"
--%>
<h3>Taglibs</h3>
<ul>
<c:forEach var="i" items="5,10,15">
<li>${i}
<c:choose>
<c:when test="${i % 2 == 0}">parzyste</c:when>
<c:otherwise>nieparzyste</c:otherwise>
</c:choose>
</li>
</c:forEach>
</ul>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment