7 Replies Latest reply: Feb 21, 2012 5:45 AM by gimbal2 RSS

    Problem with JSTL core library

    913454
      Hi All,

      I am using JDK 1.6, Tomcat 6 and Eclipse 3.3.

      New to JSP development. Trying to create a JSP page, which uses JSTL.

      In Eclipse, when I added line

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

      at the top of the page, it gives a Red cross on the left saying, 'Cannot find tag library descriptor for "http://java.sun.com/jstl/core"'.
      Why is that?
      In case of above syntax, will the JSP try to get the jar for the tag library actually from that location (URI) ?
      What is the standard practise in case of big J2EE projects? where are all tag lib files kept?

      Thanks in advance
        • 1. Re: Problem with JSTL core library
          gimbal2
          910451 wrote:
          I am using JDK 1.6, Tomcat 6 and Eclipse 3.3.
          Eclipse 3.3? Do you know how old that stuff is? Consider upgrading to Eclipse 3.7, it is a far better product.
          >
          New to JSP development. Trying to create a JSP page, which uses JSTL.

          In Eclipse, when I added line

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

          at the top of the page, it gives a Red cross on the left saying, 'Cannot find tag library descriptor for "http://java.sun.com/jstl/core"'.
          Why is that?
          Depends on what project type you created. Likely you need to either setup one of the project facets to point to the correct jars, or you need to add the JSTL jar to your project's build path.
          In case of above syntax, will the JSP try to get the jar for the tag library actually from that location (URI) ?
          No, the URI is just a label, no internet connection is created at any time. You need to add the jar to the project yourself.
          What is the standard practise in case of big J2EE projects? where are all tag lib files kept?
          In the library jars themselves, no need to do anything.
          • 2. Re: Problem with JSTL core library
            DrClap
            <%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
            That's the URI for a very old version of JSTL. Since you're using Tomcat 6 you might want to use JSP 2.0 at least; in which case your URI would be
            <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
            • 3. Re: Problem with JSTL core library
              913454
              Hi,

              I copied jstl.jar and standard.jar to Tomcat's lib folder and changed the tablib URI, everything worked.

              How to find out which version of JSP, JSTL and Servlets I am using ?

              Thanks
              • 4. Re: Problem with JSTL core library
                gimbal2
                910451 wrote:
                Hi,

                I copied jstl.jar and standard.jar to Tomcat's lib folder and changed the tablib URI, everything worked.

                How to find out which version of JSP, JSTL and Servlets I am using ?
                JSTL: well the one you downloaded of course :/ Probably inside the jar there is a META-INF/manifest.mf file which mentions a version.

                JSP/Servlet: In the web.xml you define a servlet spec version in the root webapp element. That should be version 2.5.
                • 5. Re: Problem with JSTL core library
                  rahulras
                  Hi,

                  I have Eclipse 3.5, Tomcat 6 ( 6.0.35 ), JSTL 1.1 (according to the manifest file in jstl.jar).
                  Getting the same error.

                  jstl.jar and standard.jar files are put in <webappname>\WebContent\WEB-INF\lib folder.

                  web.xml is NOT changed. Do I need to add entries like
                  <taglib>
                      <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
                      <taglib-location>/WEB-INF/c.tld</taglib-location>
                  </taglib>
                  to web.xml ? what should be the entries then for JSTL 1.1? DO I need to actually copy the .tld files to WEB-INF ?

                  Thanks
                  • 6. Re: Problem with JSTL core library
                    rahulras
                    Closed the project in Eclipse.
                    Opened it again.
                    Did a trivial change to the JSP (added a blank line), so that, I can "save" it again.
                    Saved the JSP.
                    Everything is fine now. Red cross gone, jsp running.
                    No change done to any file :-)
                    • 7. Re: Problem with JSTL core library
                      gimbal2
                      Your main problem is that you use Eclipse 3.5. I would really upgrade to 3.7 as I have yet to see these kind of things happening.
                      in any case, under Eclipse 3.5 it can help to:

                      - clean (and rebuild) the project
                      - validate the project

                      to get rid of invalid IDE problems. Closing the IDE will rarely be an actual fix, likely it is because during workspace initialization one of the two above steps was performed.