Announcement Announcement Module
Collapse
No announcement yet.
Implement JSTL tag Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Implement JSTL tag

    Currently I encounter a difficulty in resolving the JSTL tag in the JSP page, such as using <c:xxxx, it always complains about the run time expression ${status.value}.

    As someone suggested I should have the right way to implement the JSTL. I need the help to setup the following files:

    1) Under the /WEB-INF/ path, I put the file

    c.tld 1.1


    2) In the web.xml, I entered:

    <taglib>
    <taglib-uri>/WEB-INF/c</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>



    3) In the JSP page, I entered:

    <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>



    What could be wrong, missing, and how to correct them?


    Thanks.

  • #2
    You do not need a local copy of c.tld. Refer to my previous answer in this thread - http://forum.springframework.org/showthread.php?t=21093

    Bob

    Comment


    • #3
      Thanks for the response.

      When I include the taglib directive in the top of the JSP,

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

      1) Will the tag library or tld file or whatsoever, be downloaded to the session's memory address space?

      2) If YES to 1), that means the JSP does not have to "trip" to the SUN everytime in order to access the JSTL.

      3) But if NO to 1), I'll have further question to ask.


      Thanks.


      Scott

      Comment


      • #4
        You need to take a step back and read up on how JSTL tags work in JSP 2.0 environments.

        With JSP 2.0, the servlet container will auto-detect tags by looking inside the JARs in the /WEB-INF/lib for special .tld files. With this technique, it's no longer necessary to register your tags inside your web.xml.

        Now, the taglib declaration at the top of the JSP file maps a XML prefix (in this case, 'c') to some unique identifier for the tags. The unique identifier in this case is a URI. This URI matches the URI found in a .tld file, which has been auto-detected.

        Therefore, no URI is downloaded and you never need to request anything from SUN. The URI in this case is only acting as a unique identifier. Everything you need is in the .tld file (found in the JARs, like standard.jar for the JSTL)

        Comment


        • #5
          First of all, thanks for the response.

          The reason for me to raise this issue is like this: In the RAD (former IBM's Web Sphere Studio), I went to the /WEB-INF/lib to remove the jstl.jar file , re-started the web server, and then run the application. The goal is to test the JSP page in which some <c:tag are included:

          <SCRIPT LANGUAGE="Javascript" TYPE="text/javascript"><!--

          <c:choose>

          <c:when test = "${testForm.search}">
          alert('true');
          </c:when>

          //I have to leave a space between the : and o to avoid being converted to a funny icon.
          <c: otherwise >
          alert('false');
          </c: otherwise>

          </c:choose>

          --></SCRIPT>

          Since the value for the search is false, I expected the popup will display the word: false, and it did!

          Therefore, I tried to guess the JSP actually made a trip to the SUN to interprete the <c: tag. Otherewise, how should I explain it?


          Thanks.

          Scott
          Last edited by scott; Jan 6th, 2006, 01:25 PM.

          Comment


          • #6
            Originally posted by scott
            The reason for me to raise this issue is like this: In the RAD (former IBM's Web Sphere Studio), I went to the /WEB-INF/lib to remove the jstl.jar file , re-started the web server, and then run the application.
            This is why you (I'm aiming this at everyone, not you specifically) shouldn't be using an IDE until you fully understand the process of what's going on. I reckon at least 50% (possibly more) of the questions being asked on this forum would not be asked if people were learning from first principles rather than clicking boxes.

            In the class I occasionally teach at university, IDEs are banned. The students hate it at first, but they nearly all thank me later.

            Bob

            Comment


            • #7
              Many thanks. --Scott

              Comment

              Working...
              X