-1

When I develop jsp pages I use jstl.

For example I use same constructions

...
<c:forEach items="${objects}" var="object">
    <td>${object.name} </td>
</c:forEach>
...

I know that prefix c defines when I make include page. For c prefix:

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

I suppose that somewhere behind the scenes executes code(maybe java code)

Is it truthful statement ?

How do this code connects with uri?

How it works in general?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • The code JSTL tags are custom tags like any other. Consider reading a tutorial that covers making your own tags, both Java- and JSP-based. – Dave Newton Mar 17 '14 at 18:04
  • Are **java-based** and **jsp-based** differenr ways for binding jstl tags and java code? – gstackoverflow Mar 17 '14 at 18:10
  • Searching for either should be enough to answer that question. JSP-based custom tags are custom tags written entirely in JSP. Java-based custom tags are written in Java. – Dave Newton Mar 17 '14 at 18:26
  • 1
    [Here's](http://grepcode.com/file/repository.springsource.com/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.2.0/org/apache/taglibs/standard/tag/el/core/ForEachTag.java) the source code for `core:forEach` (v1.2). – Sotirios Delimanolis Mar 17 '14 at 18:27
  • nice link. I have read a class but I don't see link between **uri** and java code – gstackoverflow Mar 17 '14 at 18:42

3 Answers3

0

here you can download the source code of JSTL: http://www.java2s.com/Code/Jar/j/Downloadjstl12sourcesjar.htm

In there you will find the answer to your question: the connection between URI and prefixes.

mig8
  • 122
  • 4
0

The URI is just an identifier.If you open the c.tld file in the jstl jar files, you will see this uri declared.

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    version="2.1">

  <description>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java.sun.com/jsp/jstl/core</uri>

yes it does execute the code behind the scenes.

like for <c:forEach> you can refer to below link for source code click here

Gautam
  • 3,276
  • 4
  • 31
  • 53
-1

Using maven

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

you can attach and browse the source code in IDE.

user2418306
  • 2,352
  • 1
  • 22
  • 33