What is the proper way to read attributes of a Resource in context.xml, for
example the "url" attribute?

I am building a test web page that shows whether or not we are successfully
connected to the database. Only techies inide the company will be able to
view that web page, so security is not an issue. (I will not display
username/password anyway.)

I want to retrieve and display the url attribute for a specified Resource in
context.xml.

I know I can use XML functions to read the file, but is there a way to read
it using envContext() or something like that, after I create a Connection or
Context object?

Here are two different scenarios that begin the section of code I'm looking
for:

    Connection conn = connections.get(dataSource);
    ...

    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/MYDB");
    ...

I googled but can't find a solution.

thanks,
Harry

Reply via email to