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 Michael Duffy <du...@yahoo.com> on 2003/07/28 16:56:54 UTC

Getting default data source into JSP

I'd like to write a simple JSP that would display all
the JDBC meta-data for the default data source.  

I'm thick - how do I refer to it in the JSP?  Shawn
Bayern's "JSTL In Action" says that the constant is
Config.SQL_DATA_SOURCE, and its variable name is
javax.servlet.jsp.jstl.sql.dataSource.  What scope is
this variable in, and how can I get at it in my JSP?

It sounds like I'll have to use the rt library, since
I'd like to have JSP code that will look like this:

<c_rt:out value="<%=
dataSource.getConnection().getMetaData().getDriverMajorVersion()
%>"/>

Any advice would be appreciated.  Thanks - MOD

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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


Re: Getting default data source into JSP

Posted by Shawn Bayern <ba...@essentially.net>.
On Mon, 28 Jul 2003, Michael Duffy wrote:

> I'm thick - how do I refer to it in the JSP?  Shawn Bayern's "JSTL In
> Action" says that the constant is Config.SQL_DATA_SOURCE, and its
> variable name is javax.servlet.jsp.jstl.sql.dataSource.  What scope is
> this variable in, and how can I get at it in my JSP?
>
> It sounds like I'll have to use the rt library [...]

There is indeed a standard constant and a standard name for the
context-initialization parameter, but the data is not necessarily saved in
a particular scope with a particular name.  (If I remember correctly, this
was designed to give greater flexibility to implementations and future
versions of JSTL.)

To retrieve the data, you'll want to use the Config class itself, which
abstracts the variables for programmers.  I can't think of any way to
retrieve the information in a standard fashion using just the 'el' tags.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


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