Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use JSTL?

Tags:

jsf

jstl

Trying to use JSTL but have the following problem:

Index.xhtml page:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:jsp="http://java.sun.com/JSP/Page">
<body>
<c:out value="Hello world!"/>
</body></html>

POM:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

OUTPUT SOURCE:

        <html id="document:html" lang="en" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:jsp="http://java.sun.com/JSP/Page"><head><meta content="Rendered by ICEFaces D2D" name="icefaces" />
.....
    <c:out value="Hello world!"></c:out>
....</body></html>

As you can see its not processing the c:out but just printing it out as text.

like image 854
DD. Avatar asked Mar 03 '10 17:03

DD.


People also ask

What is the use of JSTL?

JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.

Can I use JSTL in HTML?

No. It is not possible to have JSTL in HTML page.

How do you call a method in JSTL?

The initial JSTL 1.0 EL lacked support for functions. The JSP 2.0 EL lets you call a Java class's public static method using the following syntax: ${prefix:methodName(param1, param2, ...)} The Java class doesn't have to implement any special interface.

What JSTL means?

JSTL, which stands for JavaServer Pages Standard Tag Library, is a collection of custom JSP tag libraries that provide common Web development functionality.


1 Answers

Seems that:

The solution is to remove the /jsp from the jstl namespace:

xmlns:c="http://java.sun.com/jstl/core"

See this post.

like image 50
Aito Avatar answered Oct 24 '22 20:10

Aito