The JSP does not recognize the data I give it with the servlet when I try to use JSTL. I can access the request attributes with Java code in the JSP but not using JSTL.
I am using a tomcat server. I tried changing some dependencies in the pom xml as I am using maven. Right now I am using the 1.2 version of jstl.
from the pom.xml
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>runtime</scope>
</dependency>
...
from the servlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String data = "Some data, can be a String or a Javabean";
request.setAttribute("data", data);
request.setAttribute("userList", users);
RequestDispatcher rd = request.getRequestDispatcher("/DisplayUsers.jsp");
rd.forward(request, response);
}
...
from the .jsp located in the webapp folder
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<html>
<head>
<title>Alle gespeicherten Nutzer</title>
<meta content = "text/html; charset = UTF-8"/>
</head>
<body>
<% String name = request.getAttribute("data").toString(); //this works
out.print(""+name);
%>
<p>The data from servlet: ${data}</p> // THIS DOESN´T recognize data
Expected output: The data from servlet: Some data, can be a String or a Javabean Actual output: The data from servlet: ${data}