I read the info about the JSTL tag here:
https://stackoverflow.com/tags/jstl/info
And there’s one thing I really don’t understand…
When you do reference some files like here:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
or here:
<html xmlns:c="http://java.sun.com/jsp/jstl/core">
When is this file actually read? Is this file actually read at all from the network? If that file is actually read from the network, how would development/testing be done in a highly-securized environment where there’s no external network access at all (no Internet)?
Can this file (these files) be read once and saved locally and then referenced locally?
If I try to open that webpage or to do a wget http://java.sun.com/jsp/jstl/core, I’m getting apparently something that is meant to be read by a human, not by a webapp server.
When the servletcontainer starts up, it scans the entire classpath for any
.tldfiles, including the/META-INFfolder of all deployed JAR files. The JSTL JAR file has among others ac.tldfile which starts like follows:Note the
<uri>entry. This is parsed and remembered during servletcontainer’s startup. The.tldfile declares for every single tag the tag handler class which represent the concrete Java code doing all the work “behind the scenes”. For example, the<c:out>is declared as follows:Now, when a JSP file declares a taglib with exactly this URI, then the
.tldfile in question will be used to locate the tag classes and execute them.So, the taglib URI is just a virtual address which exist only in the context of the servletcontainer and not outside, even though some taglibs happen to have a real HTTP site behind that URI. The URI is just supposed to be an unique identifier. It doesn’t necessarily need to be
http://something. It can be everything, but a website address is a relatively robust unique identifier. This guarantees almost 100% that no other taglib will have the same URI. You see this uniqueness also back in package names by the way.