How to use <c: out value = ...> taglib

I have class A:

package a;

public class A {
private int x = 9;

public int getX() {
    return x;
}
}

and ajsp.jsp file:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<jsp:useBean id = "a" class = "a.A" />
<c:out value = "${a.x}" />
</body>
</html>

when I run it, it gives an error:

  • org.apache.jasper.JasperException: /ajsp.jsp (11.0) PWC6236: According to the TLD directive or attribute in the tag file, the attribute value does not accept any expressions

If <c:out value = "${a.x}" />I use instead <jsp:getProperty property="x" name="a"/>, it will become perfect. So what's the problem? Thanks in advance.

+3
source share
1 answer

Invalid url for your taglib, you are using the URI of the old pre-expression library, pre-JSP 2.0.

Instead

http://java.sun.com/jstl/core

he should be

http://java.sun.com/jsp/jstl/core

+8
source

Source: https://habr.com/ru/post/1749737/


All Articles