0

JSP page:

<%@ page language="java" contentType="text/html; utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="sv" dir="ltr">
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>

<c:forEach begin="1" end="5" var="current">
    <c:out value="${current}"/>
    <p>${current}</p>
</c:forEach>

</body>
</html>

Maven POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>GroupName</groupId>
  <artifactId>AppName</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.19</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.14</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>Whatever</finalName>
  </build>
</project>

Instead of the output 1 2 3 4 5 I get ${current} ${current} ${current} ${current} ${current}

I code in eclipse, and I use maven for dependencies. I run code in local Tomcat Server. Might be to little background info, but its hard since Eclipse + Tomcat + Maven = 100000 ways of doing stuff, weird quirks, configurations etc. Hoping it might be something obvious.

brat
  • 586
  • 5
  • 17

1 Answers1

0

try these dependencies:

   <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.1</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

If that doesn't work, right click on the project and go into properties -> project facets.

And make sure Dynamic Web Module is 3.1

Jonathan Laliberte
  • 2,672
  • 4
  • 19
  • 44