1 2 3 4 Previous Next 49 Replies Latest reply on Oct 14, 2004 8:55 PM by 843836

    JSLT sql tag

    843836
      I have this in my jsp file and I put the jslt.jar and standard.jar in the WEB-INF\lib directory
      <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
      <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
      
      <br><br><br><br><br><br><br><br><br><br>
      <center><font face=Arial size=2>jakarta tag lib - sql! </font></center>
      
      <sql:setDataSource
        var="example"
        driver="oracle.jdbc.driver.OracleDriver"
        url="jdbc:oracle:thin:@xxxxxxx:1521:practice"
        user="xxxx"
        password="xxxxxxxx"
      />
      
      <sql:transaction dataSource="example">
      <sql:query>
          SELECT * FROM table
        </sql:query>
      </sql:transcation>
      This doesnt work.. Do I need to do anything else?

      Gives a long error message and the first line of error is
      org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/sql) cannot be resolved in either web.xml or the jar files deployed with this application
           at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:194)
           at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:174)




        • 1. Re: JSLT sql tag
          796254
          Looks to me like you got the JSTL 1.1 <c> URI correct, but the <sql> URI wrong. Change it like this:
          <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
          <%@ taglib prefix="c"; uri="http://java.sun.com/jsp/jstl/core" %>
          I'm assuming that you're using JSTL 1.1 and Tomcat 5.0

          %
          • 2. Re: JSLT sql tag
            796254
            If you set up a JNDI data source for your app, you won't have to put that connection stuff in the page.

            %
            • 3. Re: JSLT sql tag
              843836
              No that didnt work either..

              I tried different combinations of

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

              &

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

              Gives the same error

              org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jsp/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
                   at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:194)
                   at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:174)

              I can see the jar files in the lib directory.. but why doesnt this work ?


              If I use a JNDI connection then do I just use : <sql:transaction dataSource="example"> directly ?
              The dataSource in this case will be the coded name ?
              • 4. Re: JSLT sql tag
                796254
                Sounds like you're thashing.

                The URIs you should use are the ones in the TLDs in the JSTL standard.jar.

                For JSTL 1.0 it's http://java.sun.com/jstl/core
                For JSTL 1.1 it's http://java.sun.com/jsp/jstl/core

                You have to be sure that you're using the correct version.

                JSTL 1.0 is for servlet/JSP specs 2.3/1.2 (e.g., Tomcat 4.1.30)
                JSTL 1.1 is for servlet/JSP specs 2.4/2.0. (e.g., Tomcat 5.0)

                Which lib directory? Do you mean the WEB-INF/lib directory for your Web app, deployed under TOMCAT_HOME/webapps?

                No, you don't have to specify a dataSource attribute at all. If you set one up for the app, the JSP will "know" to use it.

                %
                • 5. Re: JSLT sql tag
                  794117
                  Ok.

                  1 - What servlet container are you using? Tomcat 5? Tomcat4?
                  2 - what version of JSTL do you have installed? 1.0 or 1.1?
                  3 - You don't have any entries in your web.xml for the tag libraries do you?

                  Check that in the web-inf/lib directory you have standard.jar and jstl.jar
                  Inside standard.jar (open it with winzip or some such application) you should find c.tld and sql.tld
                  Inside sql.tld you should find a line something like this:
                  <uri>http://java.sun.com/jsp/jstl/sql</uri>

                  THAT is the URI you need to load this taglibrary (phew)

                  Note that JSTL 1.1 will only work in a JSP2.0 container (ie Tomcat5, and I think Jetty5 is in now)
                  If you have a JSP1.2 Container (practically everything else BUT Tomcat5) you need to install JSTL 1.0
                  and use these tags
                  <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
                  <%@ taglib prefix="c"; uri="http://java.sun.com/jstl/core" %>

                  Cheers,
                  evnafets
                  • 6. Re: JSLT sql tag
                    843836
                    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %> -- These are the correct URLs from TLD
                    <%@ taglib prefix="c"; uri="http://java.sun.com/jsp/jstl/core" %>

                    Actually I am using the j2ee server and the deploytool that comes with j2sdkee... I have tomcat too..but I am unsure about creating a web.xml from scratch and then creating an application that recognizes my sql tags..



                    • 7. Re: JSLT sql tag
                      794117
                      hehe
                      j2sdkee actually uses Tomcat5 under the hood.


                      Can't see any problems. To my mind it looks like it should all work.
                      Try
                      - restarting j2ee
                      - start with a blank jsp page and build it up slowly. - ie add the taglib import tag, and a simple example - see if that will work. THEN try adding the SQL tags one by one.

                      Hope this helps,
                      evnafets
                      • 8. Re: JSLT sql tag
                        843836
                        Is the ; needed after the c ?
                        • 9. Re: JSLT sql tag
                          794117
                          no. It shouldn't be there.
                          • 10. Re: JSLT sql tag
                            843836
                            J2ee server is giving the same error however now Tomcat doesnt give that error anymore !!!!

                            Its a different error now :) Says transaction is unbalanced !

                            org.apache.jasper.JasperException: /ViewHelp.jsp(24,0) The end tag "</sql:transcation" is unbalanced
                                 at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
                                 at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:357)
                                 at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:125)
                            • 11. Re: JSLT sql tag
                              794117
                              </sql:transcation>
                              You mean of course transaction do you not?


                              • 12. Re: JSLT sql tag
                                796254
                                All J2EE compliant Web apps deploy with the same WAR file layout. If you deploy with a WAR (a good idea), your stuff should work under Tomcat or Sun ONE.

                                I wouldn't use the deploytool unless you knew how to do it manually. JMO, of course. I only use tools after I understand what they're doing for me.

                                %
                                • 13. Re: JSLT sql tag
                                  843836
                                  Actually I never used sun one... I am just using notepad and the compiler... and I use deploytool most of the time... Talking to you guys... I feel like I am not using anything that I should be.. But I guess I am learning..

                                  The JSLT -- >

                                  I think I am very close to getting it working... For the query in the taglib that the var is a required attribute..
                                  <attribute>
                                  <description>
                                  Name of the exported scoped variable for the
                                  query result. The type of the scoped variable is
                                  javax.servlet.jsp.jstl.sql.
                                  Result (see Chapter 16 "Java APIs").
                                  </description>
                                  <name>var</name>
                                  <required>true</required>
                                  <rtexprvalue>false</rtexprvalue>
                                  </attribute>

                                  How does it matter what value I put for the var attribute ?
                                  • 14. Re: JSLT sql tag
                                    843836
                                    Do I need to restart tomcat everytime I change a jsp ?
                                    1 2 3 4 Previous Next