0

Like a lot of people (judging by the sheer number of questions about "'http://java.sun.com/jsp/jstl/core' cannot be resolved") I'm trying to set up a simple .jsp servlet-based web app to be run in Tomcat, and finding existing documentation insufficient to actually use the java standard tag library.

I have a basic index.jsp starting with <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>, as is traditional. I bundle this into a .war with maven, deploy it to <tomcat8.5>/webapps/sandbox.war, and when I open http://localhost:8080/sandbox in my browser I get a 500 status response containing org.apache.jasper.JasperException: The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application.

My first reaction is "of course not, you would find http://java.sun.com/jsp/jstl/core at java.sun.com, not on my laptop." But it would be very strange for every JSTL application to have a hard dependency on a (non-SSL!) network resource, and indeed (http://java.sun.com/jsp/jstl/core) currently redirects to (https://www.oracle.com/java/technologies/) with a generic message alleging it is possible to harness Java. But that's not it, because as the code and error message state, http://java.sun.com/jsp/jstl/core is a uniform resource identifier, not a uniform resource locator.

So, what exactly is Jasper looking for, where is it looking for it, and how does it expect to identify that resource when it finds it?

From How to install JSTL? and other questions, it appears to be looking for a jstl-1.2.jar in <app-root>/WEB-INF/lib/. But from this question, it's more complicated than that, because their error resulted from also having a JSTL 1.0 or JSTL 1.1 jar on the classpath. That confuses me, because normally I would expect Java libraries to be located via namespace, something like import javax.servlet.jsp.jstl.*;. Is something in the .jar "labeled" with this URI? (Are there other JSTL implementations with the same URI?) Stranger, the error message suggests it's also possible to resolve the resource in web.xml, and I've never heard of embedding a .jar file directly into XML configuration.

  • URI is defined in *.tld file in JAR which are just loaded/parsed during startup. See 1st duplicate for explanation and 2nd duplicate for how to create your own. On an related side, URL format is replaced by URN format since Jakarta Tags 3.0 for precisely the reason because people get confused: https://github.com/jakartaee/tags/issues/144 -- this is also mentioned in the "How to install JSTL?" link you found. – BalusC May 19 '23 at 16:42

0 Answers0