Exception due to JodaTime JSP Taglibs working

I am trying to get the JlodaTime taglib tag working in my Spring 3 MVC application.

To the website I should be able to put this on my jsp page, and it should work.

<%@taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %> <% pageContext.setAttribute("now", new org.joda.time.DateTime()); %> <joda:format value="${now}" style="SM" /> 

I get this exception:

 org.apache.jasper.JasperException: /WEB-INF/jsp/reports/../taglibs.jspf(7,66) PWC6188: The absolute uri: http://www.joda.org/joda/time/tags cannot be resolved in either web.xml or the jar files deployed with this application 

I am running Glassfish 3.0.1. Servlet version 2.4 is declared in my web.xml file. JSP 2.1. JSTL 1.1.

Addition: I added joda-time-jsptag-1.0.2.jar to my WEB-INF / lib directory. I also have joda-time-1.6.1.jar in the same lib directory.

Should url taglib be installed? When I try to visit http://www.joda.org/joda/time/tags in my browser, it redirects to the sourceforge page. Maybe I just need an updated URI reference?

Any takers?

+4
source share
1 answer

The taglib URI does not necessarily point to a real web resource. The taglib URI must match the <uri> declaration in any of the .tld files that is present in the classpath.

Given this fact, two reasons are possible:

  • The TLD file (at least the JAR file containing it) is not at all in the classpath.
  • The TLD file declared a different URI.

I have no experience with JodaTime tags, so I cannot say from above if this incorrect behavior is incorrect. The best I can offer is to extract the JAR file containing the TLD files using some ZIP tool and then read the actual <uri> in the .tld file in the META-INF JAR folder.

If this turns out to be the same, you are likely to have a problem with the classpath or build options. Are JAR files really present in the extended WAR file in a running webapp environment?


Unrelated to a specific issue, Servlet 2.4 implies JSP 2.0, not JSP 2.1. Also, why are you using Servlet 2.4 instead of 2.5 or even 3.0? Glassfish 3 supports servlet 3.0.

+3
source

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


All Articles