Doflamingo
Doflamingo

Reputation: 217

JSTL tag is not work

I have a JSTL page and I want to print a value. This is my jstl page

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  

<html>
<head>
<title>Application</title>
</head>

<body>
<c:if test="${parameter!=null}">
    <br>
        <label><c:out value="${parameter}" /></label>
    </c:if>
</body>

The problem is that I don't read anything in the page because the code is not print. This is my pom.xml

<dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>

Servlet

String parameter="hello";

request.setAttribute("parameter", parameter);
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
            dispatcher.forward(request, response);

This is where index.jsp is located in my project:

-src
  -main
     -java
     -resources
     -webapp
        -WEB-INF
           -web.xml
        -index.jsp

Anyone can help me?

Upvotes: 0

Views: 417

Answers (1)

kiranbirajdar
kiranbirajdar

Reputation: 305

Also make sure that you added following in jsp file:-

<%@ page isELIgnored="false" %> 

EL expression:

<c:out value="${requestScope.parameter}"/>

Upvotes: 1

Related Questions