You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Matthew Lenz <ma...@nocturnal.org> on 2004/11/17 23:29:44 UTC

sql:query var empty

I'm really new to java so you'll have to forgive me.  here is the setup:

j2sdk1.4.2_06 (rpm from sun)
apache-ant-1.6.2 (from apache.org)
jakarta-tomcat-5.0.28 (from apache.org)
jakarta-taglibs-standard-1.1.2 (from apache.org)
MySQL-server-4.1.7-0 (rpm from MySQL AB)
mysql-connector-java-3.0.15-ga (zip from MySQL AB)

and I've done the following:

1. setup the JAVA_HOME and ANT_HOME environment variables
2. copied the jakarta-tomcat-5.0.28/server/lib/catalina-ant.jar
to ANT_HOME/lib
3. copied the mysql-connector-java-3.0.15-ga
to jakarta-tomcat-5.0.28/common/lib
4. copied jakarta-taglibs-standard-1.1.2/lib/*.jar
to jakarta-tomcat-5.0.28/common/lib

I already had mysql setup with some sample data and verified that the
username and password worked as well as a few queries.

I've created an example application with the following structure:

./src
./src/net
./src/net/level1tech
./src/net/level1tech/EpayManager.java
./build.xml
./web
./web/META-INF
./web/META-INF/context.xml
./web/WEB-INF
./web/WEB-INF/web.xml
./web/index.jsp
./docs
./build.properties

I modified the example build.xml file that comes with tomcat to pass a
'config' param and point to my build/META-INF/context.xml file.  I just
use it to setup the database as a Resource in the context.  I added the
corresponding resource-ref to the WEB-INF/web.xml file.  The application
has been deployed using "ant install" and everything seems to work ok.
The servlet is just a hello world type program and works fine.

Here is a copy of the index.jsp:

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

<sql:query var="rs" dataSource="jdbc/EpayManager">
SELECT username FROM tbUser
</sql:query>

<html>
  <head>
    <title>tbUser</title>
  </head>
  <body>

  <h2>Results</h2>
<c:forEach var="user" begin="0" items="${rs.rows}">
    <c:out value="${user.username}" /><br/>
</c:forEach>

Row Count: "<c:out value="${rs.rowCount}" />"<br>
  </body>
</html>

As you can see its pretty darn basic.  Here is the source for the html
that is generated:

<html>
  <head>
    <title>tbUser</title>
  </head>
  <body>

  <h2>Results</h2>
    ${user.username}<br/>

Row Count: "${rs.rowCount}"<br>
  </body>
</html>

The annoying thing is that the database is being connected to and if I
mess up the query it complains about it not being a valid query.  The
query also shows up in the mysql server log files.  I can see all the
connections etc and there are no errors in the mysql server error log
files.  So basically, the taglibs SEEM to be working, but not entirely.

I've tried adding the taglib's rar files to the WEB-INF/lib directory of
my application and adding the corresponding taglib entries in the WEB-
INF/web.xml file to no avail.  I really don't think thats it, since they
are installed in the tomcat common lib directory.


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql:query var empty

Posted by Matthew Lenz <ma...@nocturnal.org>.
----- Original Message ----- 
From: "Chris Gow" <sn...@rogers.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Wednesday, November 17, 2004 5:01 PM
Subject: Re: sql:query var empty


> On November 17, 2004 05:40 pm, Matthew Lenz wrote:
>> And after a day of messing around and 5 minutes after posting.. i find:
>>
>> http://marc.theaimsgroup.com/?l=taglibs-user&m=109948926807297&w=4
>>
>> I guess that means jakarta-taglibs-standard-1.1.2/README is a big fat
>> liar :)
> Err...not exactly. It took me a while to figure out how to correctly 
> configure
> things too. Especially when some of the examples I found online were for 
> 1.0.
>
> Anyways, I would put the http://java.sun.com/jsp/jstl/core header back 
> into
> your jsp page. What you need to do is change your taglib entry in your
> web.xml to:

actually, i was referring to the thread not that specific post.  the only 
thing that was wrong was the web.xml web-app schema links.  I fixed that and 
now it works, no need for the taglib entries in web.xml from what I can 
tell.

> <taglib>
>      <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
>      <taglib-location><!-- some/path/c.tld --></taglib-location>
>    </taglib>
>
> And make sure that the URI in the tld matches the uri specified in your
> web.xml
>
> hth
>
> -- chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql:query var empty

Posted by Chris Gow <sn...@rogers.com>.
On November 17, 2004 05:40 pm, Matthew Lenz wrote:
> And after a day of messing around and 5 minutes after posting.. i find:
>
> http://marc.theaimsgroup.com/?l=taglibs-user&m=109948926807297&w=4
>
> I guess that means jakarta-taglibs-standard-1.1.2/README is a big fat
> liar :)
Err...not exactly. It took me a while to figure out how to correctly configure 
things too. Especially when some of the examples I found online were for 1.0.

Anyways, I would put the http://java.sun.com/jsp/jstl/core header back into 
your jsp page. What you need to do is change your taglib entry in your 
web.xml to:

<taglib>
      <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
      <taglib-location><!-- some/path/c.tld --></taglib-location>
    </taglib>

And make sure that the URI in the tld matches the uri specified in your 
web.xml

hth

-- chris

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql:query var empty

Posted by Matthew Lenz <ma...@nocturnal.org>.
And after a day of messing around and 5 minutes after posting.. i find:

http://marc.theaimsgroup.com/?l=taglibs-user&m=109948926807297&w=4

I guess that means jakarta-taglibs-standard-1.1.2/README is a big fat
liar :)

good lord.

On Wed, 2004-11-17 at 16:29 -0600, Matthew Lenz wrote:
> I'm really new to java so you'll have to forgive me.  here is the setup:
> 
> j2sdk1.4.2_06 (rpm from sun)
> apache-ant-1.6.2 (from apache.org)
> jakarta-tomcat-5.0.28 (from apache.org)
> jakarta-taglibs-standard-1.1.2 (from apache.org)
> MySQL-server-4.1.7-0 (rpm from MySQL AB)
> mysql-connector-java-3.0.15-ga (zip from MySQL AB)
> 
> and I've done the following:
> 
> 1. setup the JAVA_HOME and ANT_HOME environment variables
> 2. copied the jakarta-tomcat-5.0.28/server/lib/catalina-ant.jar
> to ANT_HOME/lib
> 3. copied the mysql-connector-java-3.0.15-ga
> to jakarta-tomcat-5.0.28/common/lib
> 4. copied jakarta-taglibs-standard-1.1.2/lib/*.jar
> to jakarta-tomcat-5.0.28/common/lib
> 
> I already had mysql setup with some sample data and verified that the
> username and password worked as well as a few queries.
> 
> I've created an example application with the following structure:
> 
> ./src
> ./src/net
> ./src/net/level1tech
> ./src/net/level1tech/EpayManager.java
> ./build.xml
> ./web
> ./web/META-INF
> ./web/META-INF/context.xml
> ./web/WEB-INF
> ./web/WEB-INF/web.xml
> ./web/index.jsp
> ./docs
> ./build.properties
> 
> I modified the example build.xml file that comes with tomcat to pass a
> 'config' param and point to my build/META-INF/context.xml file.  I just
> use it to setup the database as a Resource in the context.  I added the
> corresponding resource-ref to the WEB-INF/web.xml file.  The application
> has been deployed using "ant install" and everything seems to work ok.
> The servlet is just a hello world type program and works fine.
> 
> Here is a copy of the index.jsp:
> 
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
> 
> <sql:query var="rs" dataSource="jdbc/EpayManager">
> SELECT username FROM tbUser
> </sql:query>
> 
> <html>
>   <head>
>     <title>tbUser</title>
>   </head>
>   <body>
> 
>   <h2>Results</h2>
> <c:forEach var="user" begin="0" items="${rs.rows}">
>     <c:out value="${user.username}" /><br/>
> </c:forEach>
> 
> Row Count: "<c:out value="${rs.rowCount}" />"<br>
>   </body>
> </html>
> 
> As you can see its pretty darn basic.  Here is the source for the html
> that is generated:
> 
> <html>
>   <head>
>     <title>tbUser</title>
>   </head>
>   <body>
> 
>   <h2>Results</h2>
>     ${user.username}<br/>
> 
> Row Count: "${rs.rowCount}"<br>
>   </body>
> </html>
> 
> The annoying thing is that the database is being connected to and if I
> mess up the query it complains about it not being a valid query.  The
> query also shows up in the mysql server log files.  I can see all the
> connections etc and there are no errors in the mysql server error log
> files.  So basically, the taglibs SEEM to be working, but not entirely.
> 
> I've tried adding the taglib's rar files to the WEB-INF/lib directory of
> my application and adding the corresponding taglib entries in the WEB-
> INF/web.xml file to no avail.  I really don't think thats it, since they
> are installed in the tomcat common lib directory.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org