Java: how to debug invalid JSTL declaration?

I have seen such a problem on SO (and on the Web in general) quite a few times. For example here:

JSPX namespaces not visible to EL functions?

Earlier today I tried to use JSP (regular .jsp, not.jspx), because I stupidly cut / pasted some kind of example found on the network:

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

Then my .jsp gave a blank page. There is no error message in the Tomcat log. There is nothing. Just a blank page.

Although, of course (I'm sarcastic here), the correct line was like this:

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

Missing "jsp /" (which I found a hint in another SO question).

Thus, it is obvious that such problems are common.

I can’t believe that you need to wait until something β€œworks” to know that you have a mistake there, and I'm honestly a little puzzled by the number of questions found on the network (and here on SO) where the answer is mostly " captures your declaration. "

My question here is simple: how do you know that this is a declaration problem? What thinking process is required here to diagnose and fix such problems? Are there any tools that can help here? (I don’t know, for example, IntelliJ IDEA or Eclipse or Emacs in nxml mode, warning you in real time that the declared URI is invalid?)

+4
source share
2 answers

Viewing the page source in a web browser, if you see that the tags are not parsed, then taglib is not found / loaded.

I'm not sure if I understand your last statement, but the Eclipse errors are here with a red line if taglib is not found in the classpath.

+2
source

http://java.sun.com/jstl/core is a valid JSTL declaration - this is the URI for JSTL core 1.0 . http://java.sun.com/jsp/jstl/core is the URI for JSTL core 1.1 .

+2
source

Source: https://habr.com/ru/post/1310785/


All Articles