10 Replies Latest reply on Mar 23, 2005 1:56 PM by robr

    JSP is treating an invocation of core tag as static text and

    robr

      I have written the following simple jsp that tries to use a few core tags.

      <%@ page contentType="text/html;charset=UTF-8" language="java" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c-rt" %>

      <%!
      String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
      %>


      Chapter 2 - Embedding Code

      <H1>List of people</H1>

      Name
      <c:forEach var="person" items="<%= names %>">
      <c:out value="$person" />
      </c:forEach>





      I get the following output. The $person variable gets treated as a string instead of using the value it represents.

      List of people
      Name
      $person
      $person
      $person
      $person

      I have tried for a week to get this to work. I am using JBOSS 3.2.5, JSTL 1.1, and INTELLIJ 4.5.1.

      I completed the following.

      1. I have integrated JBOSS into intellij.
      2. I can already use servlets and JSP with in my Intellij environment.
      3. I have downloaded JSTL 1.1 and moved the two .jar files (jstl.jar and standard.jar) to the the jboss/server/default/deploy folder.
      4. I copied all eight .tld files into the web_inf folder of my IntelliJ web module.
      5. Modified my web.xml file to include all the TLD files as follows for all eight.

      <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
      <taglib-location>/WEB-INF/fmt.tld</taglib-location>

      6. Added the jstl.jar and standard.jar files to the Module Libraries in the Libraries(Classpath) tab.

      Before I did step 6 anytime I tried using jstl tags the text was set to red. After 6 the code was able to find the tag information.

      Everything compiles fine. But the tag code is being piped out like it is just a string.

      Any suggestions would be greatly appreciated.

        • 1. I tried reposting the code but the HTML keeps getting interp
          robr

          How do you turn the HTML off. I clicked the Disab le HTML in post button but the HTML is ON in options.

          The code basicaly does a

          <c:forEach var="person" items="<%= names %>">
          <c:out value="$person"/>
          </c:forEach>

          If someone knows how to turn html off on the post I would appreciate it and then I will post the full code.

          • 2. Re: JSP is treating an invocation of core tag as static text
            robr

            Here is another try at the damn code. I replaced the <> with [] so the application wouldn't interpret it as HTML. Just replace [] with <> around the HTML tags and you get the real code.

            <%--
            Created by IntelliJ IDEA.
            User: Roland
            Date: Mar 10, 2005
            Time: 9:25:36 PM
            To change this template use File | Settings | File Templates.
            --%>

            <%@ page contentType="text/html;charset=UTF-8" language="java" %>
            <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
            <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c-rt" %>

            <%!
            String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
            %>

            [HTML]
            [HEAD][TITLE]Chapter 2 - Embedding Code[/TITLE][/HEAD]
            [BODY]
            <c:forEach var="person" items="<%= names %>">
            <c:out value="$person" />
            </c:forEach>
            [/BODY]
            [/HTML]


            Here is the output I get.

            $person $person $person $person

            It should be the names not the variable.

            • 3. Re: JSP is treating an invocation of core tag as static text
              cascadia4u

              try using ${person}

              • 4. Re: JSP is treating an invocation of core tag as static text
                amit.bhayani

                use

                <c:out value=" ${person}" />

                or directly use ${person} without c: tag.

                • 5. Re: JSP is treating an invocation of core tag as static text
                  robr

                  Thanks for the responses I changed the code to from what it was to the following.

                  <c:forEach var="person" items="<%= names %>">
                  <c:out value="${person}" />
                  </c:forEach>

                  It still just prints out ${person} ${person} ${person} ${person}.

                  I have actually recreated a project on my machine at work.

                  The <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                  line of code has the URI in red. If I put a mouse over it Intellij posts message that says "Cannot resolve tag library."

                  I can start the JBOSS project from within Intelij and go to the jsp in the browser and I get the strings noted above. I thought jboss would not start because of the errors in my .jsp file..

                  I don't have the "Cannot resolve tag library" in my environment at home.

                  I have added the jstl.jar and standard.jar file to the jboss/server/default/lib folder, and then added both jars to the Libraries Classpath.

                  I also added the c:\jstl\jakarta-taglibs-standard-1.1.2\tld directory. I then went into the Web Module Settings - Modules and Libraries to Package section and set the relative path for the tld libary to /WEB-INF/classes/tld.

                  I then added the taglib uri = "http://java.sun.com/jsp/jstl/core" prefix="c" tag to the jsp.

                  The program look like this. **** I have replaced the <> around the html tags with [] so that this forum will display the rest of the code correctly. Still don't know how to turn the HTML translation off. The Disable HTML in this post doesn't seem to have any affect at least in the preview.

                  <%@ page contentType="text/html;charset=UTF-8" language="java" %>
                  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                  <%!
                  String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
                  %>

                  [html]
                  [head][title]JSTL example
                  [body]
                  <c:forEach var="person" items="<%= names %>">
                  <c:out value="${person}" />
                  </c:forEach>
                  [/body]
                  [/html]



                  The web.xml file looks like this.

                  <?xml version="1.0" encoding="UTF-8"?>

                  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
                  <web-app>

                  <servlet-name>HelloServlet</servlet-name>
                  <servlet-class>com.dynix.webquotes.HelloServlet</servlet-class>

                  <servlet-mapping>
                  <servlet-name>HelloServlet</servlet-name>
                  <url-pattern>/greeting</url-pattern>
                  </servlet-mapping>
                  <ejb-ref>
                  <ejb-ref-name>ejb/hello</ejb-ref-name>
                  <ejb-ref-type>Session</ejb-ref-type>
                  com.dynix.webquote.HelloHome
                  com.dynix.webquote.Hello
                  </ejb-ref>


                  <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/fmt.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/fmt-rt</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/fmt-rt.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/c.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/core-rt</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/c-rt.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/sql.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/sql-rt</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/sql-rt.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/x</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/x.tld</taglib-location>


                  <taglib-uri>http://java.sun.com/jsp/jstl/x-rt</taglib-uri>
                  <taglib-location>/WEB-INF/classes/tld/x-rt.tld</taglib-location>


                  </web-app>


                  I have worked on this problem for over a week. I am wondering if anybody has gotten this to work with JBOSS and intellij.

                  I am wondering if I need to use the jsp-config tag? Most examples that I have seen don't use it but I wonder when it should be used.

                  • 6. Re: JSP is treating an invocation of core tag as static text
                    robr

                    Here is all my code. I figured out how to use the code button to show pure code.

                    JSTLExample.jsp

                    <%--
                     Created by IntelliJ IDEA.
                     User: rb
                     Date: Mar 21, 2005
                     Time: 1:20:14 PM
                     To change this template use File | Settings | File Templates.
                    --%>
                    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
                    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                    <%!
                     String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
                    %>
                    
                    <html>
                     <head><title>JSTL example</title></head>
                     <body>
                     <c:forEach var="person" items="<%= names %>">
                     <c:out value="${person}" />
                     </c:forEach>
                     </body>
                    </html>
                    



                    web.xml file

                    <?xml version="1.0" encoding="UTF-8"?>
                    
                    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
                    <web-app>
                     <servlet>
                     <servlet-name>HelloServlet</servlet-name>
                     <servlet-class>com.dynix.webquotes.HelloServlet</servlet-class>
                     </servlet>
                     <servlet-mapping>
                     <servlet-name>HelloServlet</servlet-name>
                     <url-pattern>/greeting</url-pattern>
                     </servlet-mapping>
                     <ejb-ref>
                     <ejb-ref-name>ejb/hello</ejb-ref-name>
                     <ejb-ref-type>Session</ejb-ref-type>
                     <home>com.dynix.webquote.HelloHome</home>
                     <remote>com.dynix.webquote.Hello</remote>
                     </ejb-ref>
                    
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/fmt.tld</taglib-location>
                     </taglib>
                    
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/fmt-rt</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/fmt-rt.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/c.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/core-rt</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/c-rt.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/sql.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/sql-rt</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/sql-rt.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/x</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/x.tld</taglib-location>
                     </taglib>
                     <taglib>
                     <taglib-uri>http://java.sun.com/jsp/jstl/x-rt</taglib-uri>
                     <taglib-location>/WEB-INF/classes/tld/x-rt.tld</taglib-location>
                     </taglib>
                    
                    </web-app>
                    
                    


                    I unzipped the web.war file in the app.ear file. The WEB-INF folder includes a /classes/tld folder that contains all the .tld files. The .tld files have a uri tag set to http://java.sun.com/jsp/jstl/core etc.

                    Is the
                    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                    tag supposed to be resolved by the some included jar files or by the .tld files? I am confused on this issue.

                    • 7. Re: JSP is treating an invocation of core tag as static text
                      robr

                      I have gotten rid of the red code on the

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

                      code.

                      I added the jstl.jar and standard.jar file from the jboss-4.0.1sp1\server\default\lib folder. Before I had them added from the Jakarta folder that I had unzipped. Don't know what the difference is. I still get the same output being...

                      ${person} ${person} ${person} ${person}

                      I am becoming convinced that I need to integrate this with Tomcat not JBOSS but I must use JBOSS so I must figure out how to make the configuration. I wish there was a way to contact JBOSS directly. Someone must have done this. Maybe not.

                      • 8. Re: JSP is treating an invocation of core tag as static text
                        robr

                        I solved the problem or I should say a really great customer support rep at Jet Brains and another support person at http://www.fuhrer.com/en/jbossplugin/.

                        The problem was that when I had set up my web module I had configured it to use version 2.3. Version 2.3 does not support JSTL tags. If you try to use them the data will be passed right through like it is a string.

                        Basically I removed the web module and then readded it using version 2.4.

                        My web.xml file now looks like the following.

                        <?xml version="1.0" encoding="UTF-8"?>
                        
                        <web-app version="2.4"
                         xmlns="http://java.sun.com/xml/ns/j2ee"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
                         <servlet>
                         <servlet-name>HelloServlet</servlet-name>
                         <servlet-class>com.dynix.webquotes.examples.HelloServlet</servlet-class>
                         </servlet>
                         <servlet-mapping>
                         <servlet-name>HelloServlet</servlet-name>
                         <url-pattern>/greeting</url-pattern>
                         </servlet-mapping>
                         <ejb-ref>
                         <ejb-ref-name>ejb/hello</ejb-ref-name>
                         <ejb-ref-type>Session</ejb-ref-type>
                         <home>com.dynix.webquote.HelloHome</home>
                         <remote>com.dynix.webquote.Hello</remote>
                         </ejb-ref>
                        </web-app>
                        


                        My JSTLExample.jsp files looks like this.

                        <%--
                         Created by IntelliJ IDEA.
                         User: rb
                         Date: Mar 23, 2005
                         Time: 10:37:55 AM
                         To change this template use File | Settings | File Templates.
                        --%>
                        <%@ page contentType="text/html;charset=UTF-8" language="java" %>
                        <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                        <%!
                         String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
                        %>
                        
                        <html>
                         <head><title>JSTL example</title></head>
                         <body>
                         <c:forEach var="person" items="<%= names %>">
                         <c:out value="${person}" />
                         </c:forEach>
                         </body>
                        </html>
                        


                        In the web Modules setting in the Libraries(Classpath) window I have added the following Jar/Directorys. I moved the jar and tld files from JAKARTA 1.1.2 unzipped folder before adding these jar/directory.

                        D:\projects\webquotes\jstl\lib\jstl.jar
                        D:\projects\webquotes\jstl\lib\jstl.jar
                        D:\projects\webquotes\jstl\tld

                        My project was created in the webquotes folder.

                        In the Web Module Settings tab of the web Modules window I made the following change under the Modules and Libraries to Package section.

                        Name Packing Method Relative
                        jstl.jar Copy files to /WEB-INF/lib/jstl.jar
                        standard.jar Copy files to /WEB-INF/lib/standard.jar
                        d:\projects\webquotes\jstl\tld Copy dir to /META-INF/tld

                        After making these changes the JSTL worked.

                        I used the following.
                        Intellij 4.5.4
                        Jboss 4.01sp1
                        Latest JBOSS plugin
                        Java jdk 1.4.2_07

                        Thanks for the replies.






                        • 9. Re: JSP is treating an invocation of core tag as static text
                          robr

                          I had read somewhere that you did not have to include the tld files in the .war file to use JSTL. I experimented some more and found this to be the case. The only thing I had to do was make sure the standard.jar and jstl.jar files were put into the WEB-INF\lib folder. It is simpler than I thought.

                          • 10. Re: JSP is treating an invocation of core tag as static text
                            robr

                            I had read somewhere that you did not have to include the tld files in the .war file to use JSTL. I experimented some more and found this to be the case. The only thing I had to do was make sure the standard.jar and jstl.jar files were put into the WEB-INF\lib folder. It is simpler than I thought.