wood burning stoves 2.0*
The moose likes JSP and the fly likes Using tags in scriptlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using tags in scriptlets" Watch "Using tags in scriptlets" New topic
Author

Using tags in scriptlets

Albert Schweitzer
Greenhorn

Joined: Oct 25, 2002
Posts: 6
Hi folks,
allthough I know that the intention of TagLibs is different, I want to
use the functionality of a tag in a scriptlet. Is there a way to do that?
And when, what does the syntax look like?
To be more concrete:
I use the Jakarta-DB-Taglib. As usuallay I make a connection. And then I
want to check the existence of a specific userID before creating it.
so what I want to do is:
- make a query
- check the rowCount
And so I assumed there is a way to do something like
....
<% if(!<db:rowCount>.equals("0")) { %>
There's allready a user with that ID!
<% } %>
.
.
.
Can anyone help? :roll:
Thanks in advance!
Albert


Kommt Zeit, kommt Bart!
Albert Schweitzer
Greenhorn

Joined: Oct 25, 2002
Posts: 6
Everything's allright! I found it myself!
If anyone is interested, here is how you can manage it.
- make a connection with the concerning tag
- start a statement tag
- after query and the result-tags, you can then access the rowcount
in a scriptlet with
(Integer)pageContext.getAttribute ("org.apache.taglibs.dbtags.resultset.rowcount");
For some this will be obvious, for me it was some kind of tricky to find!
;-D
Greetz,
Albert
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using tags in scriptlets
 
Similar Threads
Java Script variable in JSP
Replace value of XML element using API
Accessing indexed property with JSTL
session management for logout
xml in JSP page